home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / source code / Include / mymalloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-17  |  2.6 KB  |  93 lines  |  [TEXT/R*ch]

  1. #ifndef Py_MYMALLOC_H
  2. #define Py_MYMALLOC_H
  3. /***********************************************************
  4. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  5. The Netherlands.
  6.  
  7.                         All Rights Reserved
  8.  
  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.
  16.  
  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.
  24.  
  25. ******************************************************************/
  26.  
  27. /* Lowest-level memory allocation interface */
  28.  
  29. #ifdef macintosh
  30. #define ANY void
  31. #endif
  32.  
  33. #ifdef __STDC__
  34. #define ANY void
  35. #endif
  36.  
  37. #ifdef __TURBOC__
  38. #define ANY void
  39. #endif
  40.  
  41. #ifdef __GNUC__
  42. #define ANY void
  43. #endif
  44.  
  45. #ifndef ANY
  46. #define ANY char
  47. #endif
  48.  
  49. #ifdef HAVE_STDLIB_H
  50. #include <stdlib.h>
  51. #endif
  52.  
  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
  58.  
  59. #ifdef SYMANTEC__CFM68K__
  60. #pragma lib_export on
  61. #endif
  62.  
  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 */
  69.  
  70. #ifndef NULL
  71. #define NULL ((ANY *)0)
  72. #endif
  73.  
  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)
  84.  
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88.  
  89. #ifndef Py_USE_NEW_NAMES
  90. #include "rename2.h"
  91. #endif
  92. #endif /* !Py_MYMALLOC_H */
  93.