]>
Commit | Line | Data |
---|---|---|
24330d27 | 1 | /* |
4bd4418a | 2 | * $RCSId:$ |
24330d27 | 3 | * |
46b51147 | 4 | * Copyright © 2002 Keith Packard |
24330d27 KP |
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; | |
9dac3c59 | 35 | FcMemAlloc (FC_MEM_BLANKS, sizeof (FcBlanks)); |
24330d27 KP |
36 | b->nblank = 0; |
37 | b->sblank = 0; | |
38 | b->blanks = 0; | |
39 | return b; | |
40 | } | |
41 | ||
42 | void | |
43 | FcBlanksDestroy (FcBlanks *b) | |
44 | { | |
45 | if (b->blanks) | |
9dac3c59 KP |
46 | { |
47 | FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32)); | |
24330d27 | 48 | free (b->blanks); |
9dac3c59 KP |
49 | } |
50 | FcMemFree (FC_MEM_BLANKS, sizeof (FcBlanks)); | |
24330d27 KP |
51 | free (b); |
52 | } | |
53 | ||
54 | FcBool | |
55 | FcBlanksAdd (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; | |
9dac3c59 KP |
73 | if (b->sblank) |
74 | FcMemFree (FC_MEM_BLANKS, b->sblank * sizeof (FcChar32)); | |
75 | FcMemAlloc (FC_MEM_BLANKS, sblank * sizeof (FcChar32)); | |
24330d27 KP |
76 | b->sblank = sblank; |
77 | b->blanks = c; | |
78 | } | |
79 | b->blanks[b->nblank++] = ucs4; | |
80 | return FcTrue; | |
81 | } | |
82 | ||
83 | FcBool | |
84 | FcBlanksIsMember (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 | } |