1da2e3ebdSchin /***********************************************************************
2da2e3ebdSchin * *
3da2e3ebdSchin * This software is part of the ast package *
4*3e14f97fSRoger A. Faulkner * Copyright (c) 1985-2010 AT&T Intellectual Property *
5da2e3ebdSchin * and is licensed under the *
6da2e3ebdSchin * Common Public License, Version 1.0 *
77c2fbfb3SApril Chin * by AT&T Intellectual Property *
8da2e3ebdSchin * *
9da2e3ebdSchin * A copy of the License is available at *
10da2e3ebdSchin * http://www.opensource.org/licenses/cpl1.0.txt *
11da2e3ebdSchin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12da2e3ebdSchin * *
13da2e3ebdSchin * Information and Software Systems Research *
14da2e3ebdSchin * AT&T Research *
15da2e3ebdSchin * Florham Park NJ *
16da2e3ebdSchin * *
17da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> *
18da2e3ebdSchin * David Korn <dgk@research.att.com> *
19da2e3ebdSchin * Phong Vo <kpv@research.att.com> *
20da2e3ebdSchin * *
21da2e3ebdSchin ***********************************************************************/
22da2e3ebdSchin #pragma prototyped
23da2e3ebdSchin
24da2e3ebdSchin /*
25da2e3ebdSchin * posix regex state and alloc
26da2e3ebdSchin */
27da2e3ebdSchin
28da2e3ebdSchin #include "reglib.h"
29da2e3ebdSchin
307c2fbfb3SApril Chin #if _PACKAGE_ast
317c2fbfb3SApril Chin
32da2e3ebdSchin #include <ccode.h>
33da2e3ebdSchin
347c2fbfb3SApril Chin #else
357c2fbfb3SApril Chin
367c2fbfb3SApril Chin #define CC_bel '\a'
377c2fbfb3SApril Chin #define CC_esc '\033'
387c2fbfb3SApril Chin #define CC_vt '\v'
397c2fbfb3SApril Chin
407c2fbfb3SApril Chin #endif
417c2fbfb3SApril Chin
42da2e3ebdSchin /*
43da2e3ebdSchin * state shared by all threads
44da2e3ebdSchin */
45da2e3ebdSchin
46da2e3ebdSchin State_t state =
47da2e3ebdSchin {
48da2e3ebdSchin { -1, -1 },
49da2e3ebdSchin
50da2e3ebdSchin /*
51da2e3ebdSchin * escape code table
52da2e3ebdSchin * the "funny" things get special treatment at ends of BRE
53da2e3ebdSchin *
54da2e3ebdSchin * BRE 0:normal 1:escaped 2:escaped-char-class
55da2e3ebdSchin * ERE 3:normal 4:escaped 5:escaped-char-class
56da2e3ebdSchin * ARE 6:normal 7:escaped 8:escaped-char-class
57da2e3ebdSchin * SRE 9:normal 10:escaped 11:escaped-char-class
58da2e3ebdSchin * KRE 12:normal 13:escaped 14:escaped-char-class
59da2e3ebdSchin */
60da2e3ebdSchin
61da2e3ebdSchin '\\',
62da2e3ebdSchin '\\', '\\', '\\',
63da2e3ebdSchin '\\', '\\', '\\',
64da2e3ebdSchin '\\', '\\', '\\',
65da2e3ebdSchin '\\', '\\', '\\',
66da2e3ebdSchin '\\', '\\', '\\',
67da2e3ebdSchin '^', /* funny */
68da2e3ebdSchin '^', '^', '^',
69da2e3ebdSchin T_CFLX, '^', '^',
70da2e3ebdSchin T_CFLX, '^', '^',
71da2e3ebdSchin '^', '^', '^',
72da2e3ebdSchin '^', '^', '^',
73da2e3ebdSchin '.',
74da2e3ebdSchin T_DOT, '.', T_BAD,
75da2e3ebdSchin T_DOT, '.', T_BAD,
76da2e3ebdSchin T_DOT, '.', T_BAD,
77da2e3ebdSchin '.', '.', T_BAD,
78da2e3ebdSchin '.', '.', T_BAD,
79da2e3ebdSchin '$', /* funny */
80da2e3ebdSchin '$', '$', T_BAD,
81da2e3ebdSchin T_DOLL, '$', T_BAD,
82da2e3ebdSchin T_DOLL, '$', T_BAD,
83da2e3ebdSchin '$', '$', T_BAD,
84da2e3ebdSchin '$', '$', T_BAD,
85da2e3ebdSchin '*',
86da2e3ebdSchin T_STAR, '*', T_BAD,
87da2e3ebdSchin T_STAR, '*', T_BAD,
88da2e3ebdSchin T_STAR, '*', T_BAD,
89da2e3ebdSchin T_STAR, '*', '*',
90da2e3ebdSchin T_STAR, '*', '*',
91da2e3ebdSchin '[',
92da2e3ebdSchin T_BRA, '[', '[',
93da2e3ebdSchin T_BRA, '[', '[',
94da2e3ebdSchin T_BRA, '[', '[',
95da2e3ebdSchin T_BRA, '[', '[',
96da2e3ebdSchin T_BRA, '[', '[',
97da2e3ebdSchin '|',
98da2e3ebdSchin '|', T_BAD, T_BAD,
99da2e3ebdSchin T_BAR, '|', T_BAD,
100da2e3ebdSchin T_BAR, '|', T_BAD,
101da2e3ebdSchin '|', '|', T_BAD,
102da2e3ebdSchin T_BAR, '|', T_BAD,
103da2e3ebdSchin '+',
104da2e3ebdSchin '+', T_BAD, T_BAD,
105da2e3ebdSchin T_PLUS, '+', T_BAD,
106da2e3ebdSchin T_PLUS, '+', T_BAD,
107da2e3ebdSchin '+', '+', T_BAD,
108da2e3ebdSchin T_PLUS, '+', T_BAD,
109da2e3ebdSchin '?',
110da2e3ebdSchin '?', T_BAD, T_BAD,
111da2e3ebdSchin T_QUES, '?', T_BAD,
112da2e3ebdSchin T_QUES, '?', T_BAD,
113da2e3ebdSchin T_QUES, '?', '?',
114da2e3ebdSchin T_QUES, '?', '?',
115da2e3ebdSchin '(',
116da2e3ebdSchin '(', T_OPEN, T_BAD,
117da2e3ebdSchin T_OPEN, '(', T_BAD,
118da2e3ebdSchin T_OPEN, '(', T_BAD,
119da2e3ebdSchin '(', '(', '(',
120da2e3ebdSchin T_OPEN, '(', '(',
121da2e3ebdSchin ')',
122da2e3ebdSchin ')', T_CLOSE, T_BAD,
123da2e3ebdSchin T_CLOSE, ')', T_BAD,
124da2e3ebdSchin T_CLOSE, ')', T_BAD,
125da2e3ebdSchin ')', ')', ')',
126da2e3ebdSchin T_CLOSE, ')', ')',
127da2e3ebdSchin '{',
128da2e3ebdSchin '{', T_LEFT, T_BAD,
129da2e3ebdSchin T_LEFT, '{', T_BAD,
130da2e3ebdSchin T_LEFT, '{', T_BAD,
131da2e3ebdSchin '{', '{', '{',
132da2e3ebdSchin T_LEFT, '{', '{',
133da2e3ebdSchin '}',
134da2e3ebdSchin '}', T_RIGHT, T_BAD,
135da2e3ebdSchin '}', T_BAD, T_BAD,
136da2e3ebdSchin '}', T_BAD, T_BAD,
137da2e3ebdSchin '}', '}', '}',
138da2e3ebdSchin '}', '}', '}',
139da2e3ebdSchin '&',
140da2e3ebdSchin '&', T_BAD, T_BAD,
141da2e3ebdSchin '&', T_AND, T_BAD,
142da2e3ebdSchin T_AND, '&', T_BAD,
143da2e3ebdSchin '&', '&', T_BAD,
144da2e3ebdSchin T_AND, '&', T_BAD,
145da2e3ebdSchin '!',
146da2e3ebdSchin '!', T_BAD, T_BAD,
147da2e3ebdSchin '!', T_BANG, T_BAD,
148da2e3ebdSchin T_BANG, '!', T_BAD,
149da2e3ebdSchin '!', '!', T_BAD,
150da2e3ebdSchin T_BANG, '!', T_BAD,
151da2e3ebdSchin '@',
152da2e3ebdSchin '@', T_BAD, T_BAD,
153da2e3ebdSchin '@', T_BAD, T_BAD,
154da2e3ebdSchin '@', T_BAD, T_BAD,
155da2e3ebdSchin '@', '@', T_BAD,
156da2e3ebdSchin T_AT, '@', T_BAD,
157da2e3ebdSchin '~',
158da2e3ebdSchin '~', T_BAD, T_BAD,
159da2e3ebdSchin '~', T_BAD, T_BAD,
160da2e3ebdSchin '~', T_BAD, T_BAD,
161da2e3ebdSchin '~', '~', T_BAD,
162da2e3ebdSchin T_TILDE, '~', T_BAD,
163da2e3ebdSchin '%',
164da2e3ebdSchin '%', T_BAD, T_BAD,
165da2e3ebdSchin '%', T_BAD, T_BAD,
166da2e3ebdSchin '%', T_BAD, T_BAD,
167da2e3ebdSchin '%', '%', T_BAD,
168da2e3ebdSchin T_PERCENT, '%', T_BAD,
169da2e3ebdSchin '<',
170da2e3ebdSchin '<', T_LT, T_BAD,
171da2e3ebdSchin '<', T_LT, T_BAD,
172da2e3ebdSchin T_LT, '<', T_BAD,
173da2e3ebdSchin '<', '<', T_BAD,
174da2e3ebdSchin '<', '<', T_BAD,
175da2e3ebdSchin '>',
176da2e3ebdSchin '>', T_GT, T_BAD,
177da2e3ebdSchin '>', T_GT, T_BAD,
178da2e3ebdSchin T_GT, '>', T_BAD,
179da2e3ebdSchin '>', '>', T_BAD,
180da2e3ebdSchin '>', '>', T_BAD,
181da2e3ebdSchin
182da2e3ebdSchin /* backrefs */
183da2e3ebdSchin
184da2e3ebdSchin '0',
185da2e3ebdSchin '0', T_BACK+0, T_ESCAPE,
186da2e3ebdSchin '0', T_BACK+0, T_ESCAPE,
187da2e3ebdSchin '0', T_BACK+0, T_ESCAPE,
188da2e3ebdSchin '0', T_BACK+0, T_ESCAPE,
189da2e3ebdSchin '0', T_BACK+0, T_ESCAPE,
190da2e3ebdSchin '1',
191da2e3ebdSchin '1', T_BACK+1, T_ESCAPE,
192da2e3ebdSchin '1', T_BACK+1, T_ESCAPE,
193da2e3ebdSchin '1', T_BACK+1, T_ESCAPE,
194da2e3ebdSchin '1', T_BACK+1, T_ESCAPE,
195da2e3ebdSchin '1', T_BACK+1, T_ESCAPE,
196da2e3ebdSchin '2',
197da2e3ebdSchin '2', T_BACK+2, T_ESCAPE,
198da2e3ebdSchin '2', T_BACK+2, T_ESCAPE,
199da2e3ebdSchin '2', T_BACK+2, T_ESCAPE,
200da2e3ebdSchin '2', T_BACK+2, T_ESCAPE,
201da2e3ebdSchin '2', T_BACK+2, T_ESCAPE,
202da2e3ebdSchin '3',
203da2e3ebdSchin '3', T_BACK+3, T_ESCAPE,
204da2e3ebdSchin '3', T_BACK+3, T_ESCAPE,
205da2e3ebdSchin '3', T_BACK+3, T_ESCAPE,
206da2e3ebdSchin '3', T_BACK+3, T_ESCAPE,
207da2e3ebdSchin '3', T_BACK+3, T_ESCAPE,
208da2e3ebdSchin '4',
209da2e3ebdSchin '4', T_BACK+4, T_ESCAPE,
210da2e3ebdSchin '4', T_BACK+4, T_ESCAPE,
211da2e3ebdSchin '4', T_BACK+4, T_ESCAPE,
212da2e3ebdSchin '4', T_BACK+4, T_ESCAPE,
213da2e3ebdSchin '4', T_BACK+4, T_ESCAPE,
214da2e3ebdSchin '5',
215da2e3ebdSchin '5', T_BACK+5, T_ESCAPE,
216da2e3ebdSchin '5', T_BACK+5, T_ESCAPE,
217da2e3ebdSchin '5', T_BACK+5, T_ESCAPE,
218da2e3ebdSchin '5', T_BACK+5, T_ESCAPE,
219da2e3ebdSchin '5', T_BACK+5, T_ESCAPE,
220da2e3ebdSchin '6',
221da2e3ebdSchin '6', T_BACK+6, T_ESCAPE,
222da2e3ebdSchin '6', T_BACK+6, T_ESCAPE,
223da2e3ebdSchin '6', T_BACK+6, T_ESCAPE,
224da2e3ebdSchin '6', T_BACK+6, T_ESCAPE,
225da2e3ebdSchin '6', T_BACK+6, T_ESCAPE,
226da2e3ebdSchin '7',
227da2e3ebdSchin '7', T_BACK+7, T_ESCAPE,
228da2e3ebdSchin '7', T_BACK+7, T_ESCAPE,
229da2e3ebdSchin '7', T_BACK+7, T_ESCAPE,
230da2e3ebdSchin '7', T_BACK+7, T_ESCAPE,
231da2e3ebdSchin '7', T_BACK+7, T_ESCAPE,
232da2e3ebdSchin '8',
233da2e3ebdSchin '8', T_BACK+8, T_ESCAPE,
234da2e3ebdSchin '8', T_BACK+8, T_ESCAPE,
235da2e3ebdSchin '8', T_BACK+8, T_ESCAPE,
236da2e3ebdSchin '8', '8', T_ESCAPE,
237da2e3ebdSchin '8', T_BACK+8, T_ESCAPE,
238da2e3ebdSchin '9',
239da2e3ebdSchin '9', T_BACK+9, T_ESCAPE,
240da2e3ebdSchin '9', T_BACK+9, T_ESCAPE,
241da2e3ebdSchin '9', T_BACK+9, T_ESCAPE,
242da2e3ebdSchin '9', '9', T_ESCAPE,
243da2e3ebdSchin '9', T_BACK+9, T_ESCAPE,
244da2e3ebdSchin
245da2e3ebdSchin /* perl */
246da2e3ebdSchin
247da2e3ebdSchin 'A',
248da2e3ebdSchin 'A', T_BEG_STR, T_BAD,
249da2e3ebdSchin 'A', T_BEG_STR, T_BAD,
250da2e3ebdSchin 'A', T_BEG_STR, T_BAD,
251da2e3ebdSchin 'A', T_BEG_STR, T_BAD,
252da2e3ebdSchin 'A', T_BEG_STR, T_BAD,
253da2e3ebdSchin 'b',
254da2e3ebdSchin 'b', T_WORD, '\b',
255da2e3ebdSchin 'b', T_WORD, '\b',
256da2e3ebdSchin 'b', T_WORD, '\b',
257da2e3ebdSchin 'b', T_WORD, '\b',
258da2e3ebdSchin 'b', T_WORD, '\b',
259da2e3ebdSchin 'B',
260da2e3ebdSchin 'B', T_WORD_NOT, T_BAD,
261da2e3ebdSchin 'B', T_WORD_NOT, T_BAD,
262da2e3ebdSchin 'B', T_WORD_NOT, T_BAD,
263da2e3ebdSchin 'B', T_WORD_NOT, T_BAD,
264da2e3ebdSchin 'B', T_WORD_NOT, T_BAD,
265da2e3ebdSchin 'd',
266da2e3ebdSchin 'd', T_DIGIT, T_DIGIT,
267da2e3ebdSchin 'd', T_DIGIT, T_DIGIT,
268da2e3ebdSchin 'd', T_DIGIT, T_DIGIT,
269da2e3ebdSchin 'd', T_DIGIT, T_DIGIT,
270da2e3ebdSchin 'd', T_DIGIT, T_DIGIT,
271da2e3ebdSchin 'D',
272da2e3ebdSchin 'D', T_DIGIT_NOT, T_DIGIT_NOT,
273da2e3ebdSchin 'D', T_DIGIT_NOT, T_DIGIT_NOT,
274da2e3ebdSchin 'D', T_DIGIT_NOT, T_DIGIT_NOT,
275da2e3ebdSchin 'D', T_DIGIT_NOT, T_DIGIT_NOT,
276da2e3ebdSchin 'D', T_DIGIT_NOT, T_DIGIT_NOT,
277da2e3ebdSchin 's',
278da2e3ebdSchin 's', T_SPACE, T_SPACE,
279da2e3ebdSchin 's', T_SPACE, T_SPACE,
280da2e3ebdSchin 's', T_SPACE, T_SPACE,
281da2e3ebdSchin 's', T_SPACE, T_SPACE,
282da2e3ebdSchin 's', T_SPACE, T_SPACE,
283da2e3ebdSchin 'S',
284da2e3ebdSchin 'S', T_SPACE_NOT, T_SPACE_NOT,
285da2e3ebdSchin 'S', T_SPACE_NOT, T_SPACE_NOT,
286da2e3ebdSchin 'S', T_SPACE_NOT, T_SPACE_NOT,
287da2e3ebdSchin 'S', T_SPACE_NOT, T_SPACE_NOT,
288da2e3ebdSchin 'S', T_SPACE_NOT, T_SPACE_NOT,
289da2e3ebdSchin 'w',
290da2e3ebdSchin 'w', T_ALNUM, T_ALNUM,
291da2e3ebdSchin 'w', T_ALNUM, T_ALNUM,
292da2e3ebdSchin 'w', T_ALNUM, T_ALNUM,
293da2e3ebdSchin 'w', T_ALNUM, T_ALNUM,
294da2e3ebdSchin 'w', T_ALNUM, T_ALNUM,
295da2e3ebdSchin 'W',
296da2e3ebdSchin 'W', T_ALNUM_NOT, T_ALNUM_NOT,
297da2e3ebdSchin 'W', T_ALNUM_NOT, T_ALNUM_NOT,
298da2e3ebdSchin 'W', T_ALNUM_NOT, T_ALNUM_NOT,
299da2e3ebdSchin 'W', T_ALNUM_NOT, T_ALNUM_NOT,
300da2e3ebdSchin 'W', T_ALNUM_NOT, T_ALNUM_NOT,
301da2e3ebdSchin 'z',
302da2e3ebdSchin 'z', T_FIN_STR, T_BAD,
303da2e3ebdSchin 'z', T_FIN_STR, T_BAD,
304da2e3ebdSchin 'z', T_FIN_STR, T_BAD,
305da2e3ebdSchin 'z', T_FIN_STR, T_BAD,
306da2e3ebdSchin 'z', T_FIN_STR, T_BAD,
307da2e3ebdSchin 'Z',
308da2e3ebdSchin 'Z', T_END_STR, T_BAD,
309da2e3ebdSchin 'Z', T_END_STR, T_BAD,
310da2e3ebdSchin 'Z', T_END_STR, T_BAD,
311da2e3ebdSchin 'Z', T_END_STR, T_BAD,
312da2e3ebdSchin 'Z', T_END_STR, T_BAD,
313da2e3ebdSchin
314da2e3ebdSchin /* C escapes */
315da2e3ebdSchin
316da2e3ebdSchin 'a',
317da2e3ebdSchin 'a', CC_bel, CC_bel,
318da2e3ebdSchin 'a', CC_bel, CC_bel,
319da2e3ebdSchin 'a', CC_bel, CC_bel,
320da2e3ebdSchin 'a', CC_bel, CC_bel,
321da2e3ebdSchin 'a', CC_bel, CC_bel,
322da2e3ebdSchin 'c',
323da2e3ebdSchin 'c', T_ESCAPE, T_ESCAPE,
324da2e3ebdSchin 'c', T_ESCAPE, T_ESCAPE,
325da2e3ebdSchin 'c', T_ESCAPE, T_ESCAPE,
326da2e3ebdSchin 'c', T_ESCAPE, T_ESCAPE,
327da2e3ebdSchin 'c', T_ESCAPE, T_ESCAPE,
328da2e3ebdSchin 'C',
329da2e3ebdSchin 'C', T_ESCAPE, T_ESCAPE,
330da2e3ebdSchin 'C', T_ESCAPE, T_ESCAPE,
331da2e3ebdSchin 'C', T_ESCAPE, T_ESCAPE,
332da2e3ebdSchin 'C', T_ESCAPE, T_ESCAPE,
333da2e3ebdSchin 'C', T_ESCAPE, T_ESCAPE,
334da2e3ebdSchin 'e',
335da2e3ebdSchin 'e', CC_esc, CC_esc,
336da2e3ebdSchin 'e', CC_esc, CC_esc,
337da2e3ebdSchin 'e', CC_esc, CC_esc,
338da2e3ebdSchin 'e', CC_esc, CC_esc,
339da2e3ebdSchin 'e', CC_esc, CC_esc,
340da2e3ebdSchin 'E',
341da2e3ebdSchin 'E', CC_esc, CC_esc,
342da2e3ebdSchin 'E', CC_esc, CC_esc,
343da2e3ebdSchin 'E', CC_esc, CC_esc,
344da2e3ebdSchin 'E', CC_esc, CC_esc,
345da2e3ebdSchin 'E', CC_esc, CC_esc,
346da2e3ebdSchin 'f',
347da2e3ebdSchin 'f', '\f', '\f',
348da2e3ebdSchin 'f', '\f', '\f',
349da2e3ebdSchin 'f', '\f', '\f',
350da2e3ebdSchin 'f', '\f', '\f',
351da2e3ebdSchin 'f', '\f', '\f',
352da2e3ebdSchin 'n',
353da2e3ebdSchin 'n', '\n', '\n',
354da2e3ebdSchin 'n', '\n', '\n',
355da2e3ebdSchin 'n', '\n', '\n',
356da2e3ebdSchin 'n', '\n', '\n',
357da2e3ebdSchin 'n', '\n', '\n',
358da2e3ebdSchin 'r',
359da2e3ebdSchin 'r', '\r', '\r',
360da2e3ebdSchin 'r', '\r', '\r',
361da2e3ebdSchin 'r', '\r', '\r',
362da2e3ebdSchin 'r', '\r', '\r',
363da2e3ebdSchin 'r', '\r', '\r',
364da2e3ebdSchin 't',
365da2e3ebdSchin 't', '\t', '\t',
366da2e3ebdSchin 't', '\t', '\t',
367da2e3ebdSchin 't', '\t', '\t',
368da2e3ebdSchin 't', '\t', '\t',
369da2e3ebdSchin 't', '\t', '\t',
370da2e3ebdSchin 'v',
371da2e3ebdSchin 'v', CC_vt, CC_vt,
372da2e3ebdSchin 'v', CC_vt, CC_vt,
373da2e3ebdSchin 'v', CC_vt, CC_vt,
374da2e3ebdSchin 'v', CC_vt, CC_vt,
375da2e3ebdSchin 'v', CC_vt, CC_vt,
376da2e3ebdSchin 'x',
377da2e3ebdSchin 'x', T_ESCAPE, T_ESCAPE,
378da2e3ebdSchin 'x', T_ESCAPE, T_ESCAPE,
379da2e3ebdSchin 'x', T_ESCAPE, T_ESCAPE,
380da2e3ebdSchin 'x', T_ESCAPE, T_ESCAPE,
381da2e3ebdSchin 'x', T_ESCAPE, T_ESCAPE,
382da2e3ebdSchin };
383da2e3ebdSchin
384da2e3ebdSchin /*
385da2e3ebdSchin * all allocation/free done here
386da2e3ebdSchin * interface compatible with vmresize()
387da2e3ebdSchin *
388da2e3ebdSchin * malloc(n) alloc(0,n)
389da2e3ebdSchin * realloc(p,n) alloc(p,n)
390da2e3ebdSchin * free(p) alloc(p,0)
391da2e3ebdSchin */
392da2e3ebdSchin
393da2e3ebdSchin void*
alloc(register regdisc_t * disc,void * p,size_t n)394da2e3ebdSchin alloc(register regdisc_t* disc, void* p, size_t n)
395da2e3ebdSchin {
396da2e3ebdSchin if (disc->re_resizef)
397da2e3ebdSchin {
398da2e3ebdSchin if (!n && (disc->re_flags & REG_NOFREE))
399da2e3ebdSchin return 0;
400da2e3ebdSchin return (*disc->re_resizef)(disc->re_resizehandle, p, n);
401da2e3ebdSchin }
402da2e3ebdSchin else if (!n)
403da2e3ebdSchin {
404da2e3ebdSchin if (!(disc->re_flags & REG_NOFREE))
405da2e3ebdSchin free(p);
406da2e3ebdSchin return 0;
407da2e3ebdSchin }
408da2e3ebdSchin else if (p)
409da2e3ebdSchin return realloc(p, n);
410da2e3ebdSchin else
411da2e3ebdSchin return malloc(n);
412da2e3ebdSchin }
413