(py-indent-right, py-outdent-left): new commands, bound to C-c C-r and
[python/dscho.git] / Include / mymalloc.h
blobdb0c9bd4184dc5b61bc045d6b7e09ea2728185af
1 #ifndef Py_MYMALLOC_H
2 #define Py_MYMALLOC_H
3 /***********************************************************
4 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
5 The Netherlands.
7 All Rights Reserved
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 */
29 #ifdef macintosh
30 #define ANY void
31 #endif
33 #ifdef __STDC__
34 #define ANY void
35 #endif
37 #ifdef __TURBOC__
38 #define ANY void
39 #endif
41 #ifdef __GNUC__
42 #define ANY void
43 #endif
45 #ifndef ANY
46 #define ANY char
47 #endif
49 #ifdef HAVE_STDLIB_H
50 #include <stdlib.h>
51 #endif
53 #ifdef __cplusplus
54 // Move this down here since some C++ #include's don't like to be included
55 // inside an extern "C"
56 extern "C" {
57 #endif
59 #ifdef __CFM68K__
60 #pragma lib_export on
61 #endif
63 #ifndef HAVE_STDLIB_H
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 */
70 #ifndef NULL
71 #define NULL ((ANY *)0)
72 #endif
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) \
78 if ((p) == NULL) \
79 (p) = (type *) malloc(1 + (n) * sizeof(type)); \
80 else \
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)
85 #ifdef __cplusplus
87 #endif
89 #ifndef Py_USE_NEW_NAMES
90 #include "rename2.h"
91 #endif
92 #endif /* !Py_MYMALLOC_H */