blob: aadd0f30483edd8f61fbfd38f609255134d2ddc6 [file] [log] [blame]
Guido van Rossum1e28e5e1992-08-19 16:46:30 +00001/***********************************************************
2Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The
3Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
25/* Lowest-level memory allocation interface */
26
27#ifdef macintosh
28#define ANY void
29#ifndef THINK_C_3_0
30#define HAVE_STDLIB
31#endif
32#endif
33
34#ifdef sun
35/* Maybe not for very old versions of SunOS ? */
36#define HAVE_STDLIB
37#endif
38
39#ifdef sgi
40#define HAVE_STDLIB
41#endif
42
43#ifdef __STDC__
44#define ANY void
45#define HAVE_STDLIB
46#endif
47
48#ifndef ANY
49#define ANY char
50#endif
51
52#ifndef NULL
53#define NULL 0
54#endif
55
56#define NEW(type, n) ( (type *) malloc((n) * sizeof(type)) )
57#define RESIZE(p, type, n) \
58 if ((p) == NULL) \
59 (p) = (type *) malloc((n) * sizeof(type)); \
60 else \
61 (p) = (type *) realloc((ANY *)(p), (n) * sizeof(type))
62#define DEL(p) free((ANY *)p)
63#define XDEL(p) if ((p) == NULL) ; else DEL(p)
64
65#ifdef HAVE_STDLIB
66#include <stdlib.h>
67#define MALLARG size_t
68#else
69#define MALLARG size_t
70extern ANY *malloc PROTO((MALLARG));
71extern ANY *calloc PROTO((MALLARG, MALLARG));
72extern ANY *realloc PROTO((ANY *, MALLARG));
73extern void free PROTO((ANY *)); /* XXX sometimes int on Unix old systems */
74#endif