Guido van Rossum | 1e28e5e | 1992-08-19 16:46:30 +0000 | [diff] [blame] | 1 | /*********************************************************** |
| 2 | Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The |
| 3 | Netherlands. |
| 4 | |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
| 9 | provided that the above copyright notice appear in all copies and that |
| 10 | both that copyright notice and this permission notice appear in |
| 11 | supporting documentation, and that the names of Stichting Mathematisch |
| 12 | Centrum or CWI not be used in advertising or publicity pertaining to |
| 13 | distribution of the software without specific, written prior permission. |
| 14 | |
| 15 | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 16 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 17 | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
| 18 | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 20 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 21 | OF 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 |
| 70 | extern ANY *malloc PROTO((MALLARG)); |
| 71 | extern ANY *calloc PROTO((MALLARG, MALLARG)); |
| 72 | extern ANY *realloc PROTO((ANY *, MALLARG)); |
| 73 | extern void free PROTO((ANY *)); /* XXX sometimes int on Unix old systems */ |
| 74 | #endif |