home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / malloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  8.5 KB  |  228 lines

  1. #if __IBMC__ || __IBMCPP__
  2. #pragma info( none )
  3. #ifndef __CHKHDR__
  4.    #pragma info( none )
  5. #endif
  6. #pragma info( restore )
  7. #endif
  8.  
  9. #ifndef __malloc_h
  10.  #define __malloc_h
  11.  
  12.  #ifndef  _LNK_CONV
  13.     #ifdef _M_I386
  14.        #define _LNK_CONV   _Optlink
  15.     #else
  16.        #define _LNK_CONV
  17.     #endif
  18.  #endif
  19.  
  20.  #ifndef _IMPORT
  21.     #ifdef __IMPORTLIB__
  22.        #define _IMPORT _Import
  23.     #else
  24.        #define _IMPORT
  25.     #endif
  26.  #endif
  27.  
  28.  /********************************************************************/
  29.  /*  <malloc.h> header file                                          */
  30.  /*                                                                  */
  31.  /*  VisualAge for C++ for Windows, Version 3.5                      */
  32.  /*    Licensed Material - Property of IBM                           */
  33.  /*                                                                  */
  34.  /*  5801-ARR and Other Materials                                    */
  35.  /*                                                                  */
  36.  /*  (c) Copyright IBM Corp 1991, 1996. All rights reserved.         */
  37.  /*                                                                  */
  38.  /********************************************************************/
  39.  
  40.  #ifndef __size_t
  41.    #define __size_t
  42.    typedef unsigned int size_t;
  43.  #endif
  44.  
  45.  #ifndef __umalloc_h
  46.   #ifdef __cplusplus
  47.     extern "C" {
  48.   #endif
  49.  
  50.   extern int  _IMPORT _LNK_CONV _heap_walk(int (* _LNK_CONV callback)(const void *, size_t,
  51.                                 int,int ,const char *, size_t)) ;
  52.  
  53.   extern int  _IMPORT _LNK_CONV _heapset(unsigned int fill);
  54.   extern int  _IMPORT _LNK_CONV _heapchk(void);
  55.  
  56.   #define _HEAPOK        (0)
  57.   #define _HEAPEMPTY     (1)
  58.   #define _HEAPBADNODE   (2)
  59.   #define _HEAPBADBEGIN  (3)
  60.   #define _FREEENTRY     (4)
  61.   #define _USEDENTRY     (5)
  62.  
  63.   #ifdef __cplusplus
  64.     }
  65.   #endif
  66.  #endif
  67.  
  68.  #if (!defined(__stdlib_h))
  69.    #ifdef __cplusplus
  70.       extern "C" {
  71.    #endif
  72.  
  73.    #ifdef __EXTENDED__
  74.  
  75.       #ifndef __size_t
  76.         #define __size_t
  77.         typedef unsigned int size_t;
  78.       #endif
  79.  
  80.       /* Define different memory model versions of memory management       */
  81.       /* routines to the standard names.                                   */
  82.  
  83.       #define _ncalloc( x, y )  calloc( (x), (y) )
  84.       #define _fcalloc( x, y )  calloc( (x), (y) )
  85.       #define _nfree( x )       free( (x) )
  86.       #define _ffree( x )       free( (x) )
  87.       #define _nmalloc( x )     malloc( (x) )
  88.       #define _fmalloc( x )     malloc( (x) )
  89.       #define _nrealloc( x, y ) realloc( (x), (y) )
  90.       #define _frealloc( x, y ) realloc( (x), (y) )
  91.       #define _fheapmin( )      _heapmin( )
  92.       #define _nheapmin( )      _heapmin( )
  93.  
  94.       /* function prototypes */
  95.  
  96.    #if __IBMC__ || __IBMCPP__
  97.       #ifndef _alloca
  98.          void * _Builtin __alloca( size_t );
  99.          #pragma info( none )
  100.          #define _alloca( x ) __alloca( (x) )
  101.          #define alloca( x ) __alloca( (x) )
  102.          #pragma info( restore )
  103.       #endif
  104.  
  105.       #if _M_I386
  106.          unsigned char _Builtin __parmdwords( void );
  107.       #endif
  108.    #else
  109.       #ifndef _alloca
  110.          #define _alloca( x ) __alloca( (x) )
  111.          #define alloca( x ) __alloca( (x) )
  112.       #endif
  113.    #endif
  114.  
  115.       extern void * _IMPORT _LNK_CONV calloc( size_t, size_t );
  116.       extern void   _IMPORT _LNK_CONV free( void * );
  117.       extern void * _IMPORT _LNK_CONV malloc( size_t );
  118.       extern void * _IMPORT _LNK_CONV realloc( void *, size_t );
  119.       extern int    _IMPORT _LNK_CONV _heapmin(void);
  120.       extern size_t _IMPORT _LNK_CONV _msize(void *);
  121.  
  122.  
  123.  
  124.       #if defined(__TILED__) && __OS2__ && _M_IX86
  125.           extern void * _IMPORT _LNK_CONV _tcalloc( size_t, size_t );
  126.           extern void   _IMPORT _LNK_CONV _tfree( void * );
  127.           extern void * _IMPORT _LNK_CONV _tmalloc( size_t );
  128.           extern void * _IMPORT _LNK_CONV _trealloc( void *, size_t );
  129.           extern void * _IMPORT _LNK_CONV _theapmin(void);
  130.         #ifndef __DEBUG_ALLOC__
  131.           #pragma map( calloc , "_tcalloc"  )
  132.           #pragma map( free   , "_tfree"    )
  133.           #pragma map( malloc , "_tmalloc"  )
  134.           #pragma map( realloc, "_trealloc" )
  135.           #pragma map( heapmin, "_theapmin" )
  136.         #endif
  137.       #endif
  138.  
  139.       #ifdef __DEBUG_ALLOC__
  140.         #if defined(__TILED__) && __OS2__ && _M_IX86
  141.          extern void * _IMPORT _LNK_CONV _debug_tcalloc( size_t, size_t, const char *, size_t );
  142.          extern void   _IMPORT _LNK_CONV _debug_tfree( void *, const char *, size_t );
  143.          extern void * _IMPORT _LNK_CONV _debug_tmalloc( size_t, const char *, size_t );
  144.          extern void * _IMPORT _LNK_CONV _debug_trealloc( void *, size_t, const char *, size_t );
  145.          extern int    _IMPORT _LNK_CONV _debug_theapmin( const char *, size_t );
  146.          extern void   _IMPORT _LNK_CONV _theap_check( void );
  147.          extern void   _IMPORT _LNK_CONV _tdump_allocated( int );
  148.          extern void   _IMPORT _LNK_CONV _tdump_allocated_delta( int );
  149.          extern void   _IMPORT _LNK_CONV __theap_check( const char *,size_t );
  150.          extern void   _IMPORT _LNK_CONV __tdump_allocated( int ,const char *, size_t);
  151.          extern void   _IMPORT _LNK_CONV __tdump_allocated_delta( int, const char *,size_t);
  152.  
  153.          #pragma info( none )
  154.          #define _tcalloc(x,y)  _debug_tcalloc( (x), (y), __FILE__, __LINE__ )
  155.          #define _tfree( x )    _debug_tfree( (x), __FILE__, __LINE__ )
  156.          #define _tmalloc( x )  _debug_tmalloc( (x), __FILE__, __LINE__ )
  157.          #define _trealloc(x,y) _debug_trealloc( (x), (y), __FILE__, __LINE__ )
  158.          #define _theapmin( )   _debug_theapmin( __FILE__, __LINE__ )
  159.  
  160.          #define calloc(x,y)    _debug_tcalloc( (x), (y), __FILE__, __LINE__ )
  161.          #define free( x )      _debug_tfree( (x), __FILE__, __LINE__ )
  162.          #define malloc( x )    _debug_tmalloc( (x), __FILE__, __LINE__ )
  163.          #define realloc(x,y)   _debug_trealloc( (x), (y), __FILE__, __LINE__ )
  164.          #define _heapmin( )    _debug_theapmin( __FILE__, __LINE__ )
  165.  
  166.          #define _heap_check()            __theap_check(__FILE__,__LINE__)
  167.          #define _dump_allocated(x)       __tdump_allocated((x),__FILE__,__LINE__)
  168.          #define _dump_allocated_delta(x) __tdump_allocated_delta((x),__FILE__,__LINE__)
  169.  
  170.          #pragma info( restore )
  171.         #else
  172.          extern void * _IMPORT _LNK_CONV _debug_calloc( size_t, size_t, const char *, size_t );
  173.          extern void   _IMPORT _LNK_CONV _debug_free( void *, const char *, size_t );
  174.          extern void * _IMPORT _LNK_CONV _debug_malloc( size_t, const char *, size_t );
  175.          extern void * _IMPORT _LNK_CONV _debug_realloc( void *, size_t, const char *, size_t );
  176.          extern int    _IMPORT _LNK_CONV _debug_heapmin( const char *, size_t );
  177.          extern void   _IMPORT _LNK_CONV _heap_check( void );
  178.          extern void   _IMPORT _LNK_CONV _dump_allocated( int );
  179.          extern void   _IMPORT _LNK_CONV _dump_allocated_delta( int );
  180.          extern void   _IMPORT _LNK_CONV __heap_check( const char *,size_t );
  181.          extern void   _IMPORT _LNK_CONV __dump_allocated( int ,const char *, size_t);
  182.          extern void   _IMPORT _LNK_CONV __dump_allocated_delta( int, const char *, size_t);
  183.  
  184.          #if __IBMC__ || __IBMCPP__
  185.            #pragma info( none )
  186.          #endif
  187.          #define calloc( x, y )  _debug_calloc( (x), (y), __FILE__, __LINE__ )
  188.          #define free( x )       _debug_free( (x), __FILE__, __LINE__ )
  189.          #define malloc( x )     _debug_malloc( (x), __FILE__, __LINE__ )
  190.          #define realloc( x, y ) _debug_realloc( (x), (y), __FILE__, __LINE__ )
  191.          #define _heapmin( )     _debug_heapmin( __FILE__, __LINE__ )
  192.  
  193.          #define _heap_check()            __heap_check(__FILE__,__LINE__)
  194.          #define _dump_allocated(x)       __dump_allocated((x),__FILE__,__LINE__)
  195.          #define _dump_allocated_delta(x) __dump_allocated_delta((x),__FILE__,__LINE__)
  196.  
  197.          #if __IBMC__ || __IBMCPP__
  198.            #pragma info( restore )
  199.          #endif
  200.         #endif
  201.       #else
  202.          #define _heap_check( )
  203.          #define _dump_allocated( x )
  204.          #define _theap_check( )
  205.          #define _tdump_allocated( x )
  206.          #define _dump_allocated_delta( x )
  207.          #define _tdump_allocated_delta( x )
  208.       #endif
  209.  
  210.  
  211.    #endif
  212.  
  213.   #ifdef __cplusplus
  214.     }
  215.   #endif
  216.  
  217.  #endif
  218. #endif
  219.  
  220. #if __IBMC__ || __IBMCPP__
  221. #pragma info( none )
  222. #ifndef __CHKHDR__
  223.    #pragma info( restore )
  224. #endif
  225. #pragma info( restore )
  226. #endif
  227.  
  228.