home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / MALLOC.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  4KB  |  156 lines

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