3 /***********************************************************
4 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
9 Permission to use, copy, modify, and distribute this software and its
10 documentation for any purpose and without fee is hereby granted,
11 provided that the above copyright notice appear in all copies and that
12 both that copyright notice and this permission notice appear in
13 supporting documentation, and that the names of Stichting Mathematisch
14 Centrum or CWI not be used in advertising or publicity pertaining to
15 distribution of the software without specific, written prior permission.
17 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
18 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
20 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
22 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
23 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ******************************************************************/
27 /* Lowest-level memory allocation interface */
54 // Move this down here since some C++ #include's don't like to be included
55 // inside an extern "C"
64 extern ANY
*malloc
Py_PROTO((size_t));
65 extern ANY
*calloc
Py_PROTO((size_t, size_t));
66 extern ANY
*realloc
Py_PROTO((ANY
*, size_t));
67 extern void free
Py_PROTO((ANY
*)); /* XXX sometimes int on Unix old systems */
68 #endif /* !HAVE_STDLIB */
71 #define NULL ((ANY *)0)
74 /* XXX Always allocate one extra byte, since some malloc's return NULL
75 XXX for malloc(0) or realloc(p, 0). */
76 #define PyMem_NEW(type, n) ( (type *) malloc(1 + (n) * sizeof(type)) )
77 #define PyMem_RESIZE(p, type, n) \
79 (p) = (type *) malloc(1 + (n) * sizeof(type)); \
81 (p) = (type *) realloc((ANY *)(p), 1 + (n) * sizeof(type))
82 #define PyMem_DEL(p) free((ANY *)p)
83 #define PyMem_XDEL(p) if ((p) == NULL) ; else PyMem_DEL(p)
89 #ifndef Py_USE_NEW_NAMES
92 #endif /* !Py_MYMALLOC_H */