home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / utils / palloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.1 KB  |  120 lines

  1. /*
  2.  * palloc.h --
  3.  *    POSTGRES memory allocator definitions.
  4.  */
  5.  
  6. #ifndef    PAllocIncluded        /* Include this file only once */
  7. #define PAllocIncluded    1
  8.  
  9. /*
  10.  * Identification:
  11.  */
  12. #define PALLOC_H    "$Header: /private/postgres/src/lib/H/utils/RCS/palloc.h,v 1.8 1991/11/12 20:24:42 mer Exp $"
  13.  
  14. #include "tmp/c.h"
  15. #include "tmp/simplelists.h"
  16.  
  17. /*
  18.  * palloc --
  19.  *    Returns pointer to aligned memory of specified size.
  20.  *
  21.  * Exceptions:
  22.  *    BadArgument if size < 1 or size >= MaxAllocSize.
  23.  *    ExhaustedMemory if allocation fails.
  24.  *    NonallocatedPointer if pointer was not returned by palloc or repalloc
  25.  *        or may have been freed already.
  26.  *
  27.  * pfree --
  28.  *    Frees memory associated with pointer returned from palloc or repalloc.
  29.  *
  30.  * Exceptions:
  31.  *    BadArgument if pointer is invalid.
  32.  *    FreeInWrongContext if pointer was allocated in a different "context."
  33.  *    NonallocatedPointer if pointer was not returned by palloc or repalloc
  34.  *        or may have been subsequently freed.
  35.  */
  36.  
  37. #ifndef PALLOC_DEBUG
  38. extern Pointer palloc ARGS((Size size));
  39. extern void    pfree  ARGS((Pointer pointer)); 
  40. #else
  41. Pointer palloc_debug ARGS((String file , int line , Size size ));
  42. void pfree_debug ARGS((String file , int line , Pointer pointer ));
  43. #endif PALLOC_DEBUG
  44.  
  45. typedef struct PallocDebugData {
  46.     Pointer     pointer;
  47.     Size        size;
  48.     String      file;
  49.     int         line;
  50.     String      context;
  51.     SLNode      Link;
  52. } PallocDebugData;
  53.  
  54. /*
  55.  * psize --
  56.  *    Returns size of memory returned from palloc or repalloc.
  57.  *
  58.  * Note:
  59.  *    Psize may be called on objects allocated in other memory contexts.
  60.  *
  61.  * Exceptions:
  62.  *    BadArgument if pointer is invalid.
  63.  *    NonallocatedPointer if pointer was not returned by palloc or repalloc
  64.  *        or may have been freed already.
  65.  */
  66. extern
  67. Size
  68. psize ARGS((
  69.     Pointer    pointer
  70. ));
  71.  
  72. /*
  73.  * repalloc --
  74.  *    Returns pointer to aligned memory of specified size.
  75.  *
  76.  * Side effects:
  77.  *    The returned memory is first filled with the contents of *pointer
  78.  *    up to the minimum of size and psize(pointer).  Pointer is freed.
  79.  *
  80.  * Exceptions:
  81.  *    BadArgument if pointer is invalid or size < 1 or size >= MaxAllocSize.
  82.  *    ExhaustedMemory if allocation fails.
  83.  *    NonallocatedPointer if pointer was not returned by palloc or repalloc
  84.  *        or may have been freed already.
  85.  */
  86. extern
  87. Pointer
  88. repalloc ARGS((
  89.     Pointer    pointer,
  90.     Size    size
  91. ));
  92.  
  93. String pcontext ARGS((void ));
  94. void set_palloc_debug ARGS((bool noisy , bool record ));
  95. Pointer palloc_record ARGS((
  96.     String file,
  97.     int line,
  98.     Size size,
  99.     String context
  100. ));
  101. void pfree_remove ARGS((String file , int line , Pointer pointer ));
  102. void pfree_record ARGS((String file , int line , Pointer pointer ));
  103. void dump_palloc_list ARGS((String caller , bool verbose ));
  104. void alloc_set_message ARGS((
  105.     String file,
  106.     int line,
  107.     Pointer pointer,
  108.     Pointer set
  109. ));
  110. void free_palloc_list ARGS((SLList *list ));
  111. void start_palloc_list ARGS((void ));
  112. void print_palloc_list ARGS((void ));
  113. void start_palloc_diff_list ARGS((void ));
  114. void end_palloc_diff_list ARGS((void ));
  115. void print_palloc_diff_list ARGS((void ));
  116. char *malloc_debug ARGS((String file , int line , int size ));
  117. int free_debug ARGS((String file , int line , char *p ));
  118.  
  119. #endif /* !defined(PAllocIncluded) */
  120.