intl/hyphenation/src/hnjalloc.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial