]> git.wh0rd.org - fontconfig.git/blob - src/fcblanks.c
Initial revision
[fontconfig.git] / src / fcblanks.c
1 /*
2 * $XFree86$
3 *
4 * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
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
27 FcBlanks *
28 FcBlanksCreate (void)
29 {
30 FcBlanks *b;
31
32 b = malloc (sizeof (FcBlanks));
33 if (!b)
34 return 0;
35 b->nblank = 0;
36 b->sblank = 0;
37 b->blanks = 0;
38 return b;
39 }
40
41 void
42 FcBlanksDestroy (FcBlanks *b)
43 {
44 if (b->blanks)
45 free (b->blanks);
46 free (b);
47 }
48
49 FcBool
50 FcBlanksAdd (FcBlanks *b, FcChar32 ucs4)
51 {
52 FcChar32 *c;
53 int sblank;
54
55 for (sblank = 0; sblank < b->nblank; sblank++)
56 if (b->blanks[sblank] == ucs4)
57 return FcTrue;
58
59 if (b->nblank == b->sblank)
60 {
61 sblank = b->sblank + 32;
62 if (b->blanks)
63 c = (FcChar32 *) realloc (b->blanks, sblank * sizeof (FcChar32));
64 else
65 c = (FcChar32 *) malloc (sblank * sizeof (FcChar32));
66 if (!c)
67 return FcFalse;
68 b->sblank = sblank;
69 b->blanks = c;
70 }
71 b->blanks[b->nblank++] = ucs4;
72 return FcTrue;
73 }
74
75 FcBool
76 FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
77 {
78 int i;
79
80 for (i = 0; i < b->nblank; i++)
81 if (b->blanks[i] == ucs4)
82 return FcTrue;
83 return FcFalse;
84 }