home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-base.tgz / octave-1.1.1p1-base.tar / fsf / octave / kpathsea / malloc.h < prev    next >
C/C++ Source or Header  |  1994-09-08  |  4KB  |  117 lines

  1. /*  Author: Mark Moraes <moraes@csri.toronto.edu> */
  2. /* $Id: malloc.h,v 1.1 1994/09/08 21:36:26 jwe Exp $ */
  3. #ifndef __XMALLOC_H__
  4. #define __XMALLOC_H__
  5.  
  6. #define MALLOC_TRACE /* my one modification */
  7.  
  8. #if defined(ANSI_TYPES) || defined(__STDC__)
  9. #define univptr_t        void *
  10. #else    /* ! ANSI_TYPES */
  11. #define univptr_t        char *
  12. #define    size_t        unsigned int
  13. #endif    /* ANSI_TYPES */
  14.  
  15. #if defined(ANSI_TYPES) && !defined(__STDC__)
  16. #define size_t        unsigned long
  17. #endif
  18.  
  19. #if defined(__STDC__)
  20. #define __proto(x)    x
  21. #else
  22. #define __proto(x)    ()
  23. #endif
  24.  
  25. /*
  26.  *  defined so users of new features of this malloc can #ifdef
  27.  *  invocations of those features.
  28.  */
  29. #define CSRIMALLOC
  30.  
  31. #ifdef MALLOC_TRACE
  32. /* Tracing malloc definitions - helps find leaks */
  33.  
  34. extern univptr_t __malloc __proto((size_t, const char *, int));
  35. extern univptr_t __calloc __proto((size_t, size_t, const char *, int));
  36. extern univptr_t __realloc __proto((univptr_t, size_t, const char *, int));
  37. extern univptr_t __valloc __proto((size_t, const char *, int));
  38. extern univptr_t __memalign __proto((size_t, size_t, const char *, int));
  39. extern univptr_t __emalloc __proto((size_t, const char *, int));
  40. extern univptr_t __ecalloc __proto((size_t, size_t, const char *, int));
  41. extern univptr_t __erealloc __proto((univptr_t, size_t, const char *, int));
  42. extern char *__strdup __proto((const char *, const char *, int));
  43. extern char *__strsave __proto((const char *, const char *, int));
  44. extern void __free __proto((univptr_t, const char *, int));
  45. extern void __cfree __proto((univptr_t, const char *, int));
  46.  
  47. #define malloc(x)        __malloc((x), __FILE__, __LINE__)
  48. #define calloc(x, n)        __calloc((x), (n), __FILE__, __LINE__)
  49. #define realloc(p, x)        __realloc((p), (x), __FILE__, __LINE__)
  50. #define memalign(x, n)        __memalign((x), (n), __FILE__, __LINE__)
  51. #define valloc(x)        __valloc((x), __FILE__, __LINE__)
  52. #define emalloc(x)        __emalloc((x), __FILE__, __LINE__)
  53. #define ecalloc(x, n)        __ecalloc((x), (n), __FILE__, __LINE__)
  54. #define erealloc(p, x)        __erealloc((p), (x), __FILE__, __LINE__)
  55. #define strdup(p)        __strdup((p), __FILE__, __LINE__)
  56. #define strsave(p)        __strsave((p), __FILE__, __LINE__)
  57. /* cfree and free are identical */
  58. #define cfree(p)        __free((p), __FILE__, __LINE__)
  59. #define free(p)            __free((p), __FILE__, __LINE__)
  60.  
  61. #else /* MALLOC_TRACE */
  62.  
  63. extern univptr_t malloc __proto((size_t));
  64. extern univptr_t calloc __proto((size_t, size_t));
  65. extern univptr_t realloc __proto((univptr_t, size_t));
  66. extern univptr_t valloc __proto((size_t));
  67. extern univptr_t memalign __proto((size_t, size_t));
  68. extern univptr_t emalloc __proto((size_t));
  69. extern univptr_t ecalloc __proto((size_t, size_t));
  70. extern univptr_t erealloc __proto((univptr_t, size_t));
  71. extern char *strdup __proto((const char *));
  72. extern char *strsave __proto((const char *));
  73. extern void free __proto((univptr_t));
  74. extern void cfree __proto((univptr_t));
  75.  
  76. #endif /* MALLOC_TRACE */
  77.  
  78. extern void mal_debug __proto((int));
  79. extern void mal_dumpleaktrace __proto((FILE *));
  80. extern void mal_heapdump __proto((FILE *));
  81. extern void mal_leaktrace __proto((int));
  82. extern void mal_sbrkset __proto((int));
  83. extern void mal_slopset __proto((int));
  84. extern void mal_statsdump __proto(());
  85. extern void mal_setstatsfile __proto((FILE *));
  86. extern void mal_trace __proto((int));
  87. extern int mal_verify __proto((int));
  88. extern void mal_mmap __proto((char *));
  89.  
  90.  
  91. /*
  92.  *  You may or may not want this - In gcc version 1.30, on Sun3s running
  93.  *  SunOS3.5, this works fine.
  94.  */
  95. #ifdef __GNUC__
  96. #define alloca(n) __builtin_alloca(n)
  97. #endif /* __GNUC__ */
  98. #ifdef sparc
  99. #define alloca(n) __builtin_alloca(n)
  100. #endif /* sparc */
  101.  
  102. #ifdef ANSI_TYPES
  103. #undef univptr_t
  104. #else    /* ! ANSI_TYPES */
  105. #undef univptr_t
  106. #undef size_t
  107. #endif    /* ANSI_TYPES */
  108.  
  109. /* Just in case you want an ANSI malloc without an ANSI compiler */
  110. #if defined(ANSI_TYPES) && !defined(__STDC__)
  111. #undef size_t
  112. #endif
  113.  
  114. #undef __proto
  115.  
  116. #endif /* __XMALLOC_H__ */ /* Do not add anything after this line */
  117.