intl/hyphenation/src/hnjalloc.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     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/. */
     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  */
    13 #include "mozilla/mozalloc.h"
    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)
    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  */
    26 #include <stdio.h> /* ensure stdio.h is loaded before our macros */
    28 #undef FILE
    29 #define FILE hnjFile
    31 #define fopen(path,mode)      hnjFopen(path,mode)
    32 #define fclose(file)          hnjFclose(file)
    33 #define fgets(buf,count,file) hnjFgets(buf,count,file)
    35 typedef struct hnjFile_ hnjFile;
    37 #ifdef __cplusplus
    38 extern "C" {
    39 #endif
    41 hnjFile* hnjFopen(const char* aURISpec, const char* aMode);
    43 int hnjFclose(hnjFile* f);
    45 char* hnjFgets(char* s, int n, hnjFile* f);
    47 #ifdef __cplusplus
    48 }
    49 #endif

mercurial