intl/hyphenation/src/hnjalloc.h

branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
equal deleted inserted replaced
-1:000000000000 0:2ade67baff0d
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /*
7 * Simple replacement for hnjalloc.h from libhyphen-2.x, to use moz_x* memory
8 * allocation functions. Note that the hyphen.c code does *NOT* check for
9 * NULL from memory (re)allocation, so it is essential that we use the
10 * "infallible" moz_x* variants here.
11 */
12
13 #include "mozilla/mozalloc.h"
14
15 #define hnj_malloc(size) moz_xmalloc(size)
16 #define hnj_realloc(p, size) moz_xrealloc(p, size)
17 #define hnj_free(p) moz_free(p)
18
19 /*
20 * To enable us to load hyphenation dictionaries from arbitrary resource URIs,
21 * not just through file paths using stdio, we override the (few) stdio APIs
22 * that hyphen.c uses and provide our own reimplementation that calls Gecko
23 * i/o methods.
24 */
25
26 #include <stdio.h> /* ensure stdio.h is loaded before our macros */
27
28 #undef FILE
29 #define FILE hnjFile
30
31 #define fopen(path,mode) hnjFopen(path,mode)
32 #define fclose(file) hnjFclose(file)
33 #define fgets(buf,count,file) hnjFgets(buf,count,file)
34
35 typedef struct hnjFile_ hnjFile;
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 hnjFile* hnjFopen(const char* aURISpec, const char* aMode);
42
43 int hnjFclose(hnjFile* f);
44
45 char* hnjFgets(char* s, int n, hnjFile* f);
46
47 #ifdef __cplusplus
48 }
49 #endif
50
51

mercurial