3 * Copyright (c) 1991-2000, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
10 #if !defined(__STDC__)
21 #define Null(type) ((type)NULL)
24 =for apidoc AmU||Nullch
25 Null character pointer.
27 =for apidoc AmU||Nullsv
33 #define Nullch Null(char*)
34 #define Nullfp Null(PerlIO*)
35 #define Nullsv Null(SV*)
47 /* XXX Configure ought to have a test for a boolean type, if I can
48 just figure out all the headers such a test needs.
49 Andy Dougherty August 1996
51 /* bool is built-in for g++-2.6.3, which might be used for an extension.
52 If the extension includes <_G_config.h> before this file then
53 _G_HAVE_BOOL will be properly set. If, however, the extension includes
54 this file first, then you will have to manually set -DHAS_BOOL in
55 your command line to avoid a conflict.
65 /* The NeXT dynamic loader headers will not build with the bool macro
66 So declare them now to clear confusion.
68 #if defined(NeXT) || defined(__NeXT__)
71 typedef enum bool { FALSE = 0, TRUE = 1 } bool;
75 # endif /* !HAS_BOOL */
76 #endif /* NeXT || __NeXT__ */
79 # if defined(UTS) || defined(VMS)
86 /* XXX A note on the perl source internal type system. The
87 original intent was that I32 be *exactly* 32 bits.
89 Currently, we only guarantee that I32 is *at least* 32 bits.
90 Specifically, if int is 64 bits, then so is I32. (This is the case
91 for the Cray.) This has the advantage of meshing nicely with
92 standard library calls (where we pass an I32 and the library is
93 expecting an int), but the disadvantage that an I32 is not 32 bits.
94 Andy Dougherty August 1996
96 There is no guarantee that there is *any* integral type with
97 exactly 32 bits. It is perfectly legal for a system to have
98 sizeof(short) == sizeof(int) == sizeof(long) == 8.
100 Similarly, there is no guarantee that I16 and U16 have exactly 16
103 For dealing with issues that may arise from various 32/64-bit
104 systems, we will ask Configure to check out
106 SHORTSIZE == sizeof(short)
107 INTSIZE == sizeof(int)
108 LONGSIZE == sizeof(long)
109 LONGLONGSIZE == sizeof(long long) (if HAS_LONG_LONG)
110 PTRSIZE == sizeof(void *)
111 DOUBLESIZE == sizeof(double)
112 LONG_DOUBLESIZE == sizeof(long double) (if HAS_LONG_DOUBLE).
124 # if QUADKIND == QUAD_IS_INT64_T
125 # include <sys/types.h>
126 # ifdef I_INTTYPES /* e.g. Linux has int64_t without <inttypes.h> */
127 # include <inttypes.h>
133 #endif /* PERL_CORE */
135 /* Mention I8SIZE, U8SIZE, I16SIZE, U16SIZE, I32SIZE, U32SIZE,
136 I64SIZE, and U64SIZE here so that metaconfig pulls them in. */
138 #if defined(UINT8_MAX) && defined(INT16_MAX) && defined(INT32_MAX)
140 /* I8_MAX and I8_MIN constants are not defined, as I8 is an ambiguous type.
141 Please search CHAR_MAX in perl.h for further details. */
142 #define U8_MAX UINT8_MAX
143 #define U8_MIN UINT8_MIN
145 #define I16_MAX INT16_MAX
146 #define I16_MIN INT16_MIN
147 #define U16_MAX UINT16_MAX
148 #define U16_MIN UINT16_MIN
150 #define I32_MAX INT32_MAX
151 #define I32_MIN INT32_MIN
152 #define U32_MAX UINT32_MAX
153 #define U32_MIN UINT32_MIN
157 /* I8_MAX and I8_MIN constants are not defined, as I8 is an ambiguous type.
158 Please search CHAR_MAX in perl.h for further details. */
159 #define U8_MAX PERL_UCHAR_MAX
160 #define U8_MIN PERL_UCHAR_MIN
162 #define I16_MAX PERL_SHORT_MAX
163 #define I16_MIN PERL_SHORT_MIN
164 #define U16_MAX PERL_USHORT_MAX
165 #define U16_MIN PERL_USHORT_MIN
168 # define I32_MAX PERL_INT_MAX
169 # define I32_MIN PERL_INT_MIN
170 # define U32_MAX PERL_UINT_MAX
171 # define U32_MIN PERL_UINT_MIN
173 # define I32_MAX PERL_LONG_MAX
174 # define I32_MIN PERL_LONG_MIN
175 # define U32_MAX PERL_ULONG_MAX
176 # define U32_MIN PERL_ULONG_MIN
181 #define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */
182 #define TYPE_DIGITS(T) BIT_DIGITS(sizeof(T) * 8)
183 #define TYPE_CHARS(T) (TYPE_DIGITS(T) + 2) /* sign, NUL */
185 #define Ctl(ch) ((ch) & 037)
188 =for apidoc Am|bool|strNE|char* s1|char* s2
189 Test two strings to see if they are different. Returns true or
192 =for apidoc Am|bool|strEQ|char* s1|char* s2
193 Test two strings to see if they are equal. Returns true or false.
195 =for apidoc Am|bool|strLT|char* s1|char* s2
196 Test two strings to see if the first, C<s1>, is less than the second,
197 C<s2>. Returns true or false.
199 =for apidoc Am|bool|strLE|char* s1|char* s2
200 Test two strings to see if the first, C<s1>, is less than or equal to the
201 second, C<s2>. Returns true or false.
203 =for apidoc Am|bool|strGT|char* s1|char* s2
204 Test two strings to see if the first, C<s1>, is greater than the second,
205 C<s2>. Returns true or false.
207 =for apidoc Am|bool|strGE|char* s1|char* s2
208 Test two strings to see if the first, C<s1>, is greater than or equal to
209 the second, C<s2>. Returns true or false.
211 =for apidoc Am|bool|strnNE|char* s1|char* s2|STRLEN len
212 Test two strings to see if they are different. The C<len> parameter
213 indicates the number of bytes to compare. Returns true or false. (A
214 wrapper for C<strncmp>).
216 =for apidoc Am|bool|strnEQ|char* s1|char* s2|STRLEN len
217 Test two strings to see if they are equal. The C<len> parameter indicates
218 the number of bytes to compare. Returns true or false. (A wrapper for
224 #define strNE(s1,s2) (strcmp(s1,s2))
225 #define strEQ(s1,s2) (!strcmp(s1,s2))
226 #define strLT(s1,s2) (strcmp(s1,s2) < 0)
227 #define strLE(s1,s2) (strcmp(s1,s2) <= 0)
228 #define strGT(s1,s2) (strcmp(s1,s2) > 0)
229 #define strGE(s1,s2) (strcmp(s1,s2) >= 0)
230 #define strnNE(s1,s2,l) (strncmp(s1,s2,l))
231 #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l))
234 # define memNE(s1,s2,l) (memcmp(s1,s2,l))
235 # define memEQ(s1,s2,l) (!memcmp(s1,s2,l))
237 # define memNE(s1,s2,l) (bcmp(s1,s2,l))
238 # define memEQ(s1,s2,l) (!bcmp(s1,s2,l))
244 * Unfortunately, the introduction of locales means that we
245 * can't trust isupper(), etc. to tell the truth. And when
246 * it comes to /\w+/ with tainting enabled, we *must* be able
247 * to trust our character classes.
249 * Therefore, the default tests in the text of Perl will be
250 * independent of locale. Any code that wants to depend on
251 * the current locale will use the tests that begin with "lc".
254 #ifdef HAS_SETLOCALE /* XXX Is there a better test for this? */
261 =for apidoc Am|bool|isALNUM|char ch
262 Returns a boolean indicating whether the C C<char> is an ascii alphanumeric
265 =for apidoc Am|bool|isALPHA|char ch
266 Returns a boolean indicating whether the C C<char> is an ascii alphabetic
269 =for apidoc Am|bool|isSPACE|char ch
270 Returns a boolean indicating whether the C C<char> is whitespace.
272 =for apidoc Am|bool|isDIGIT|char ch
273 Returns a boolean indicating whether the C C<char> is an ascii
276 =for apidoc Am|bool|isUPPER|char ch
277 Returns a boolean indicating whether the C C<char> is an uppercase
280 =for apidoc Am|bool|isLOWER|char ch
281 Returns a boolean indicating whether the C C<char> is a lowercase
284 =for apidoc Am|char|toUPPER|char ch
285 Converts the specified character to uppercase.
287 =for apidoc Am|char|toLOWER|char ch
288 Converts the specified character to lowercase.
293 #define isALNUM(c) (isALPHA(c) || isDIGIT(c) || (c) == '_')
294 #define isIDFIRST(c) (isALPHA(c) || (c) == '_')
295 #define isALPHA(c) (isUPPER(c) || isLOWER(c))
297 ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) =='\r' || (c) == '\f')
298 #define isDIGIT(c) ((c) >= '0' && (c) <= '9')
300 /* In EBCDIC we do not do locales: therefore() isupper() is fine. */
301 # define isUPPER(c) isupper(c)
302 # define isLOWER(c) islower(c)
303 # define isALNUMC(c) isalnum(c)
304 # define isASCII(c) isascii(c)
305 # define isCNTRL(c) iscntrl(c)
306 # define isGRAPH(c) isgraph(c)
307 # define isPRINT(c) isprint(c)
308 # define isPUNCT(c) ispunct(c)
309 # define isXDIGIT(c) isxdigit(c)
310 # define toUPPER(c) toupper(c)
311 # define toLOWER(c) tolower(c)
313 # define isUPPER(c) ((c) >= 'A' && (c) <= 'Z')
314 # define isLOWER(c) ((c) >= 'a' && (c) <= 'z')
315 # define isALNUMC(c) (isALPHA(c) || isDIGIT(c))
316 # define isASCII(c) ((c) <= 127)
317 # define isCNTRL(c) ((c) < ' ')
318 # define isGRAPH(c) (isALNUM(c) || isPUNCT(c))
319 # define isPRINT(c) (((c) > 32 && (c) < 127) || isSPACE(c))
320 # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126))
321 # define isXDIGIT(c) (isdigit(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
322 # define toUPPER(c) (isLOWER(c) ? (c) - ('a' - 'A') : (c))
323 # define toLOWER(c) (isUPPER(c) ? (c) + ('a' - 'A') : (c))
326 #ifdef USE_NEXT_CTYPE
328 # define isALNUM_LC(c) \
329 (NXIsAlNum((unsigned int)(c)) || (char)(c) == '_')
330 # define isIDFIRST_LC(c) \
331 (NXIsAlpha((unsigned int)(c)) || (char)(c) == '_')
332 # define isALPHA_LC(c) NXIsAlpha((unsigned int)(c))
333 # define isSPACE_LC(c) NXIsSpace((unsigned int)(c))
334 # define isDIGIT_LC(c) NXIsDigit((unsigned int)(c))
335 # define isUPPER_LC(c) NXIsUpper((unsigned int)(c))
336 # define isLOWER_LC(c) NXIsLower((unsigned int)(c))
337 # define isALNUMC_LC(c) NXIsAlNum((unsigned int)(c))
338 # define isCNTRL_LC(c) NXIsCntrl((unsigned int)(c))
339 # define isGRAPH_LC(c) NXIsGraph((unsigned int)(c))
340 # define isPRINT_LC(c) NXIsPrint((unsigned int)(c))
341 # define isPUNCT_LC(c) NXIsPunct((unsigned int)(c))
342 # define toUPPER_LC(c) NXToUpper((unsigned int)(c))
343 # define toLOWER_LC(c) NXToLower((unsigned int)(c))
345 #else /* !USE_NEXT_CTYPE */
347 # if defined(CTYPE256) || (!defined(isascii) && !defined(HAS_ISASCII))
349 # define isALNUM_LC(c) (isalnum((unsigned char)(c)) || (char)(c) == '_')
350 # define isIDFIRST_LC(c) (isalpha((unsigned char)(c)) || (char)(c) == '_')
351 # define isALPHA_LC(c) isalpha((unsigned char)(c))
352 # define isSPACE_LC(c) isspace((unsigned char)(c))
353 # define isDIGIT_LC(c) isdigit((unsigned char)(c))
354 # define isUPPER_LC(c) isupper((unsigned char)(c))
355 # define isLOWER_LC(c) islower((unsigned char)(c))
356 # define isALNUMC_LC(c) isalnum((unsigned char)(c))
357 # define isCNTRL_LC(c) iscntrl((unsigned char)(c))
358 # define isGRAPH_LC(c) isgraph((unsigned char)(c))
359 # define isPRINT_LC(c) isprint((unsigned char)(c))
360 # define isPUNCT_LC(c) ispunct((unsigned char)(c))
361 # define toUPPER_LC(c) toupper((unsigned char)(c))
362 # define toLOWER_LC(c) tolower((unsigned char)(c))
366 # define isALNUM_LC(c) (isascii(c) && (isalnum(c) || (c) == '_'))
367 # define isIDFIRST_LC(c) (isascii(c) && (isalpha(c) || (c) == '_'))
368 # define isALPHA_LC(c) (isascii(c) && isalpha(c))
369 # define isSPACE_LC(c) (isascii(c) && isspace(c))
370 # define isDIGIT_LC(c) (isascii(c) && isdigit(c))
371 # define isUPPER_LC(c) (isascii(c) && isupper(c))
372 # define isLOWER_LC(c) (isascii(c) && islower(c))
373 # define isALNUMC_LC(c) (isascii(c) && isalnum(c))
374 # define isCNTRL_LC(c) (isascii(c) && iscntrl(c))
375 # define isGRAPH_LC(c) (isascii(c) && isgraph(c))
376 # define isPRINT_LC(c) (isascii(c) && isprint(c))
377 # define isPUNCT_LC(c) (isascii(c) && ispunct(c))
378 # define toUPPER_LC(c) toupper(c)
379 # define toLOWER_LC(c) tolower(c)
382 #endif /* USE_NEXT_CTYPE */
384 #define isALNUM_uni(c) is_uni_alnum(c)
385 #define isIDFIRST_uni(c) is_uni_idfirst(c)
386 #define isALPHA_uni(c) is_uni_alpha(c)
387 #define isSPACE_uni(c) is_uni_space(c)
388 #define isDIGIT_uni(c) is_uni_digit(c)
389 #define isUPPER_uni(c) is_uni_upper(c)
390 #define isLOWER_uni(c) is_uni_lower(c)
391 #define isALNUMC_uni(c) is_uni_alnumc(c)
392 #define isASCII_uni(c) is_uni_ascii(c)
393 #define isCNTRL_uni(c) is_uni_cntrl(c)
394 #define isGRAPH_uni(c) is_uni_graph(c)
395 #define isPRINT_uni(c) is_uni_print(c)
396 #define isPUNCT_uni(c) is_uni_punct(c)
397 #define isXDIGIT_uni(c) is_uni_xdigit(c)
398 #define toUPPER_uni(c) to_uni_upper(c)
399 #define toTITLE_uni(c) to_uni_title(c)
400 #define toLOWER_uni(c) to_uni_lower(c)
402 #define isALNUM_LC_uni(c) (c < 256 ? isALNUM_LC(c) : is_uni_alnum_lc(c))
403 #define isIDFIRST_LC_uni(c) (c < 256 ? isIDFIRST_LC(c) : is_uni_idfirst_lc(c))
404 #define isALPHA_LC_uni(c) (c < 256 ? isALPHA_LC(c) : is_uni_alpha_lc(c))
405 #define isSPACE_LC_uni(c) (c < 256 ? isSPACE_LC(c) : is_uni_space_lc(c))
406 #define isDIGIT_LC_uni(c) (c < 256 ? isDIGIT_LC(c) : is_uni_digit_lc(c))
407 #define isUPPER_LC_uni(c) (c < 256 ? isUPPER_LC(c) : is_uni_upper_lc(c))
408 #define isLOWER_LC_uni(c) (c < 256 ? isLOWER_LC(c) : is_uni_lower_lc(c))
409 #define isALNUMC_LC_uni(c) (c < 256 ? isALNUMC_LC(c) : is_uni_alnumc_lc(c))
410 #define isCNTRL_LC_uni(c) (c < 256 ? isCNTRL_LC(c) : is_uni_cntrl_lc(c))
411 #define isGRAPH_LC_uni(c) (c < 256 ? isGRAPH_LC(c) : is_uni_graph_lc(c))
412 #define isPRINT_LC_uni(c) (c < 256 ? isPRINT_LC(c) : is_uni_print_lc(c))
413 #define isPUNCT_LC_uni(c) (c < 256 ? isPUNCT_LC(c) : is_uni_punct_lc(c))
414 #define toUPPER_LC_uni(c) (c < 256 ? toUPPER_LC(c) : to_uni_upper_lc(c))
415 #define toTITLE_LC_uni(c) (c < 256 ? toUPPER_LC(c) : to_uni_title_lc(c))
416 #define toLOWER_LC_uni(c) (c < 256 ? toLOWER_LC(c) : to_uni_lower_lc(c))
418 #define isALNUM_utf8(p) is_utf8_alnum(p)
419 #define isIDFIRST_utf8(p) is_utf8_idfirst(p)
420 #define isALPHA_utf8(p) is_utf8_alpha(p)
421 #define isSPACE_utf8(p) is_utf8_space(p)
422 #define isDIGIT_utf8(p) is_utf8_digit(p)
423 #define isUPPER_utf8(p) is_utf8_upper(p)
424 #define isLOWER_utf8(p) is_utf8_lower(p)
425 #define isALNUMC_utf8(p) is_utf8_alnumc(p)
426 #define isASCII_utf8(p) is_utf8_ascii(p)
427 #define isCNTRL_utf8(p) is_utf8_cntrl(p)
428 #define isGRAPH_utf8(p) is_utf8_graph(p)
429 #define isPRINT_utf8(p) is_utf8_print(p)
430 #define isPUNCT_utf8(p) is_utf8_punct(p)
431 #define isXDIGIT_utf8(p) is_utf8_xdigit(p)
432 #define toUPPER_utf8(p) to_utf8_upper(p)
433 #define toTITLE_utf8(p) to_utf8_title(p)
434 #define toLOWER_utf8(p) to_utf8_lower(p)
436 #define isALNUM_LC_utf8(p) isALNUM_LC_uni(utf8_to_uv(p, 0))
437 #define isIDFIRST_LC_utf8(p) isIDFIRST_LC_uni(utf8_to_uv(p, 0))
438 #define isALPHA_LC_utf8(p) isALPHA_LC_uni(utf8_to_uv(p, 0))
439 #define isSPACE_LC_utf8(p) isSPACE_LC_uni(utf8_to_uv(p, 0))
440 #define isDIGIT_LC_utf8(p) isDIGIT_LC_uni(utf8_to_uv(p, 0))
441 #define isUPPER_LC_utf8(p) isUPPER_LC_uni(utf8_to_uv(p, 0))
442 #define isLOWER_LC_utf8(p) isLOWER_LC_uni(utf8_to_uv(p, 0))
443 #define isALNUMC_LC_utf8(p) isALNUMC_LC_uni(utf8_to_uv(p, 0))
444 #define isCNTRL_LC_utf8(p) isCNTRL_LC_uni(utf8_to_uv(p, 0))
445 #define isGRAPH_LC_utf8(p) isGRAPH_LC_uni(utf8_to_uv(p, 0))
446 #define isPRINT_LC_utf8(p) isPRINT_LC_uni(utf8_to_uv(p, 0))
447 #define isPUNCT_LC_utf8(p) isPUNCT_LC_uni(utf8_to_uv(p, 0))
448 #define toUPPER_LC_utf8(p) toUPPER_LC_uni(utf8_to_uv(p, 0))
449 #define toTITLE_LC_utf8(p) toTITLE_LC_uni(utf8_to_uv(p, 0))
450 #define toLOWER_LC_utf8(p) toLOWER_LC_uni(utf8_to_uv(p, 0))
453 EXT int ebcdic_control (int);
454 # define toCTRL(c) ebcdic_control(c)
456 /* This conversion works both ways, strangely enough. */
457 # define toCTRL(c) (toUPPER(c) ^ 64)
460 /* Line numbers are unsigned, 16 bits. */
463 #define NOLINE ((line_t)0)
465 #define NOLINE ((line_t) 65535)
469 /* This looks obsolete (IZ):
471 XXX LEAKTEST doesn't really work in perl5. There are direct calls to
472 safemalloc() in the source, so LEAKTEST won't pick them up.
473 Further, if you try LEAKTEST, you'll also end up calling
474 Safefree, which might call safexfree() on some things that weren't
475 malloced with safexmalloc. The correct "fix" to this, if anyone
476 is interested, is to ensure that all calls go through the New and
478 --Andy Dougherty August 1996
482 =for apidoc Am|SV*|NEWSV|int id|STRLEN len
483 Creates a new SV. A non-zero C<len> parameter indicates the number of
484 bytes of preallocated string space the SV should have. An extra byte for a
485 tailing NUL is also reserved. (SvPOK is not set for the SV even if string
486 space is allocated.) The reference count for the new SV is set to 1.
487 C<id> is an integer id between 0 and 1299 (used to identify leaks).
489 =for apidoc Am|void|New|int id|void* ptr|int nitems|type
490 The XSUB-writer's interface to the C C<malloc> function.
492 =for apidoc Am|void|Newc|int id|void* ptr|int nitems|type|cast
493 The XSUB-writer's interface to the C C<malloc> function, with
496 =for apidoc Am|void|Newz|int id|void* ptr|int nitems|type
497 The XSUB-writer's interface to the C C<malloc> function. The allocated
498 memory is zeroed with C<memzero>.
500 =for apidoc Am|void|Renew|void* ptr|int nitems|type
501 The XSUB-writer's interface to the C C<realloc> function.
503 =for apidoc Am|void|Renewc|void* ptr|int nitems|type|cast
504 The XSUB-writer's interface to the C C<realloc> function, with
507 =for apidoc Am|void|Safefree|void* src|void* dest|int nitems|type
508 The XSUB-writer's interface to the C C<free> function.
510 =for apidoc Am|void|Move|void* src|void* dest|int nitems|type
511 The XSUB-writer's interface to the C C<memmove> function. The C<src> is the
512 source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
513 the type. Can do overlapping moves. See also C<Copy>.
515 =for apidoc Am|void|Copy|void* src|void* dest|int nitems|type
516 The XSUB-writer's interface to the C C<memcpy> function. The C<src> is the
517 source, C<dest> is the destination, C<nitems> is the number of items, and C<type> is
518 the type. May fail on overlapping copies. See also C<Move>.
520 =for apidoc Am|void|Zero|void* dest|int nitems|type
522 The XSUB-writer's interface to the C C<memzero> function. The C<dest> is the
523 destination, C<nitems> is the number of items, and C<type> is the type.
525 =for apidoc Am|void|StructCopy|type src|type dest|type
526 This is an architecture-independant macro to copy one structure to another.
533 #define NEWSV(x,len) newSV(len)
537 #define New(x,v,n,t) (v = (t*)safemalloc((MEM_SIZE)((n)*sizeof(t))))
538 #define Newc(x,v,n,t,c) (v = (c*)safemalloc((MEM_SIZE)((n)*sizeof(t))))
539 #define Newz(x,v,n,t) (v = (t*)safemalloc((MEM_SIZE)((n)*sizeof(t)))), \
540 memzero((char*)(v), (n)*sizeof(t))
541 #define Renew(v,n,t) \
542 (v = (t*)saferealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t))))
543 #define Renewc(v,n,t,c) \
544 (v = (c*)saferealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t))))
545 #define Safefree(d) safefree((Malloc_t)(d))
549 #define New(x,v,n,t) (v = (t*)safexmalloc((x),(MEM_SIZE)((n)*sizeof(t))))
550 #define Newc(x,v,n,t,c) (v = (c*)safexmalloc((x),(MEM_SIZE)((n)*sizeof(t))))
551 #define Newz(x,v,n,t) (v = (t*)safexmalloc((x),(MEM_SIZE)((n)*sizeof(t)))), \
552 memzero((char*)(v), (n)*sizeof(t))
553 #define Renew(v,n,t) \
554 (v = (t*)safexrealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t))))
555 #define Renewc(v,n,t,c) \
556 (v = (c*)safexrealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t))))
557 #define Safefree(d) safexfree((Malloc_t)(d))
559 #define MAXXCOUNT 1400
561 #define MAXYCOUNT 16 /* (MAXY_SIZE/4 + 1) */
562 extern long xcount[MAXXCOUNT];
563 extern long lastxcount[MAXXCOUNT];
564 extern long xycount[MAXXCOUNT][MAXYCOUNT];
565 extern long lastxycount[MAXXCOUNT][MAXYCOUNT];
567 #endif /* LEAKTEST */
569 #define Move(s,d,n,t) (void)memmove((char*)(d),(char*)(s), (n) * sizeof(t))
570 #define Copy(s,d,n,t) (void)memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
571 #define Zero(d,n,t) (void)memzero((char*)(d), (n) * sizeof(t))
575 #define New(x,v,n,s) (v = Null(s *))
576 #define Newc(x,v,n,s,c) (v = Null(s *))
577 #define Newz(x,v,n,s) (v = Null(s *))
578 #define Renew(v,n,s) (v = Null(s *))
579 #define Move(s,d,n,t)
580 #define Copy(s,d,n,t)
582 #define Safefree(d) (d) = (d)
586 #ifdef USE_STRUCT_COPY
587 #define StructCopy(s,d,t) (*((t*)(d)) = *((t*)(s)))
589 #define StructCopy(s,d,t) Copy(s,d,1,t)