home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / MALLOC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-18  |  3.6 KB  |  160 lines

  1. /*  malloc.h
  2.  
  3.     memory management functions and variables.
  4.  
  5. */
  6.  
  7. /* $Copyright: 1991$ */
  8. /* $Revision:   8.1  $ */
  9.  
  10. #ifndef __MALLOC_H
  11. #define __MALLOC_H
  12.  
  13. #include <alloc.h>
  14.  
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18.  
  19.  
  20. #if !defined(RC_INVOKED)
  21.  
  22. #if defined(__STDC__)
  23. #pragma warn -nak
  24. #endif
  25.  
  26. #endif  /* !RC_INVOKED */
  27.  
  28.  
  29. #if !defined(__FLAT__) && !defined(__ALLOC_H)
  30. #include <alloc.h>
  31. #endif
  32.  
  33.  
  34. #ifndef _SIZE_T
  35.   #define _SIZE_T
  36.   typedef unsigned size_t;
  37. #endif
  38.  
  39. #if !defined(_Windows) || defined(__FLAT__)
  40.  
  41. #if !defined(RC_INVOKED)
  42. #pragma pack(push, 1)
  43. #endif
  44.  
  45. /* _HEAPINFO structure returned by heapwalk */
  46.  
  47. typedef struct _heapinfo
  48. {
  49.     int     *_pentry;
  50.     int     *__pentry;
  51.     size_t  _size;
  52.     int     _useflag;
  53. } _HEAPINFO;
  54.  
  55.  
  56. #if !defined(RC_INVOKED)
  57. /* restore default packing */
  58. #pragma pack(pop)
  59. #endif
  60.  
  61. #endif  /* _Windows */
  62.  
  63.  
  64. #if !defined(__FLAT__)
  65.  
  66. #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  67.  
  68. /* Near heap functions currently allowed only in small data models */
  69.  
  70. #define _nmalloc(size)          malloc(size)
  71. #define _nfree(block)           free(block)
  72. #define _nrealloc(block,size)   realloc(block,size)
  73. #define _ncalloc(num,size)      calloc(num,size)
  74. #define _nheapmin()             0
  75. #if !defined(_Windows)
  76. #define _memavl()               coreleft()
  77. #endif
  78.  
  79. #endif  /* small data models */
  80.  
  81. /* Model-independent functions */
  82.  
  83. #define _fmalloc(size)          farmalloc((unsigned long)(size))
  84. #define _ffree(block)           farfree(block)
  85. #define _frealloc(block,size)   farrealloc(block,(unsigned long)(size))
  86. #define _fcalloc(num,size)      farcalloc((unsigned long)(num),(unsigned long)(size))
  87. #define halloc(num,size)        (void huge *)farmalloc((unsigned long)(num)*(size))
  88. #define hfree(block)            farfree((void far *)(block))
  89. #define _heapmin()              0
  90. #define _fheapmin()             0
  91.  
  92. #if !defined(_Windows)
  93. int         _RTLENTRY _EXPFUNC _heapwalk   (_HEAPINFO *__entry);
  94. #endif
  95.  
  96. /* Prototypes */
  97.  
  98. void *      _Cdecl alloca     (size_t __size);
  99. void *      _Cdecl __alloca__ (size_t __size);
  100.  
  101. #if defined(__BCOPT__ ) && !defined(_Windows)
  102. #undef      alloca      /* to remove a redefinition warning */
  103. #define     alloca(__size)  __alloca__(__size)
  104. #endif
  105.  
  106. size_t      _Cdecl stackavail (void);
  107.  
  108. #else  /* __FLAT__ */
  109.  
  110. /* Prototypes */
  111.  
  112. void *      __cdecl   _EXPFUNC alloca( size_t __size );
  113. void *      __cdecl            __alloca__ (size_t __size);
  114.  
  115. #if (__CGVER__ >= 0x200)
  116.   #define alloca(__size)       __alloca__(__size)
  117.   #if defined(__MFC_COMPAT__)
  118.     #define _alloca(__size)    __alloca__(__size)
  119.   #endif
  120. #else
  121.   #if defined(__MFC_COMPAT__)
  122.     #define _alloca alloca
  123.   #endif
  124. #endif
  125.  
  126.  
  127. size_t      _RTLENTRY _EXPFUNC stackavail  (void);
  128. int         _RTLENTRY _EXPFUNC _heapadd    (void * __block, size_t __size);
  129. int         _RTLENTRY _EXPFUNC _heapchk    (void);
  130. int         _RTLENTRY _EXPFUNC _heapmin    (void);
  131. int         _RTLENTRY _EXPFUNC _heapset    (unsigned int __fill);
  132. int         _RTLENTRY _EXPFUNC _heapwalk   (_HEAPINFO *__entry);
  133. int         _RTLENTRY _EXPFUNC _rtl_heapwalk (_HEAPINFO *__entry);
  134. void *      _RTLENTRY _EXPFUNC _expand     (void * __block, size_t __size);
  135. size_t      _RTLENTRY _EXPFUNC _msize      (void * __block );
  136.  
  137.  
  138. #endif  /* __FLAT__ */
  139.  
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143.  
  144. /* Obsolete functions */
  145. #if !defined(RC_INVOKED) && (!defined(_Windows) || defined(__FLAT__))
  146. #pragma obsolete _heapwalk
  147. #endif
  148.  
  149.  
  150. #if !defined(RC_INVOKED)
  151.  
  152. #if defined(__STDC__)
  153. #pragma warn .nak
  154. #endif
  155.  
  156. #endif  /* !RC_INVOKED */
  157.  
  158.  
  159. #endif  /* __MALLOC_H */
  160.