source: trunk/poppler/fontconfig-2.3.2-os2/src/fcblanks.c @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 15 years ago

First import

File size: 2.4 KB
Line 
1/*
2 * $RCSId:$
3 *
4 * Copyright © 2002 Keith Packard
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission.  Keith Packard makes no
13 * representations about the suitability of this software for any purpose.  It
14 * is provided "as is" without express or implied warranty.
15 *
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
23 */
24
25#include "fcint.h"
26
27FcBlanks *
28FcBlanksCreate (void)
29{
30    FcBlanks    *b;
31
32    b = malloc (sizeof (FcBlanks));
33    if (!b)
34        return 0;
35    FcMemAlloc (FC_MEM_BLANKS, sizeof (FcBlanks));
36    b->nblank = 0;
37    b->sblank = 0;
38    b->blanks = 0;
39    return b;
40}
41
42void
43FcBlanksDestroy (FcBlanks *b)
44{
45    if (b->blanks)
46    {
47        FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32));
48        free (b->blanks);
49    }
50    FcMemFree (FC_MEM_BLANKS, sizeof (FcBlanks));
51    free (b);
52}
53
54FcBool
55FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
56{
57    FcChar32    *c;
58    int         sblank;
59
60    for (sblank = 0; sblank < b->nblank; sblank++)
61        if (b->blanks[sblank] == ucs4)
62            return FcTrue;
63
64    if (b->nblank == b->sblank)
65    {
66        sblank = b->sblank + 32;
67        if (b->blanks)
68            c = (FcChar32 *) realloc (b->blanks, sblank * sizeof (FcChar32));
69        else
70            c = (FcChar32 *) malloc (sblank * sizeof (FcChar32));
71        if (!c)
72            return FcFalse;
73        if (b->sblank)
74            FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32));
75        FcMemAlloc (FC_MEM_BLANKS, sblank * sizeof (FcChar32));
76        b->sblank = sblank;
77        b->blanks = c;
78    }
79    b->blanks[b->nblank++] = ucs4;
80    return FcTrue;
81}
82
83FcBool
84FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
85{
86    int i;
87
88    for (i = 0; i < b->nblank; i++)
89        if (b->blanks[i] == ucs4)
90            return FcTrue;
91    return FcFalse;
92}
Note: See TracBrowser for help on using the repository browser.