]> git.wh0rd.org - fontconfig.git/blame - src/fcblanks.c
Bug 44826 - <alias> must contain only a single <family>
[fontconfig.git] / src / fcblanks.c
CommitLineData
24330d27 1/*
317b8492 2 * fontconfig/src/fcblanks.c
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
5aaf466d 10 * documentation, and that the name of the author(s) not be used in
24330d27 11 * advertising or publicity pertaining to distribution of the software without
5aaf466d 12 * specific, written prior permission. The authors make no
24330d27
KP
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
15 *
3074a73b 16 * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
24330d27 17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
3074a73b 18 * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24330d27
KP
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;
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
42void
43FcBlanksDestroy (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
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;
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
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}
23816bf9
KP
93#define __fcblanks__
94#include "fcaliastail.h"
95#undef __fcblanks__