home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / lib / ds / plarenas.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.9 KB  |  96 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #if defined(PLARENAS_H)
  20. #else  /* defined(PLARENAS_H) */
  21.  
  22. PR_BEGIN_EXTERN_C
  23.  
  24. typedef struct PLArenaPool      PLArenaPool;
  25.  
  26. /*
  27. ** Allocate an arena pool as specified by the parameters.
  28. **
  29. ** This is equivelant to allocating the space yourself and then
  30. ** calling PL_InitArenaPool().
  31. **
  32. ** This function may fail (and return a NULL) for a variety of
  33. ** reasons. The reason for a particular failure can be discovered
  34. ** by calling PR_GetError().
  35. */
  36. #if 0  /* Not implemented */
  37. PR_EXTERN(PLArenaPool*) PL_AllocArenaPool(
  38.     const char *name, PRUint32 size, PRUint32 align);
  39. #endif
  40.  
  41. /*
  42. ** Destroy an arena pool previously allocated by PL_AllocArenaPool().
  43. **
  44. ** This function may fail if the arena is not empty and the caller
  45. ** wishes to check for empty upon descruction.
  46. */
  47. #if 0  /* Not implemented */
  48. PR_EXTERN(PRStatus) PL_DestroyArenaPool(PLArenaPool *pool, PRBool checkEmpty);
  49. #endif
  50.  
  51.  
  52. /*
  53. ** Initialize an arena pool with the given name for debugging and metering,
  54. ** with a minimum size per arena of size bytes.
  55. **/
  56. PR_EXTERN(void) PL_InitArenaPool(
  57.     PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
  58.  
  59. /*
  60. ** Finish using arenas, freeing all memory associated with them.
  61. **/
  62. PR_EXTERN(void) PL_ArenaFinish(void);
  63.  
  64. /*
  65. ** Free the arenas in pool.  The user may continue to allocate from pool
  66. ** after calling this function.  There is no need to call PL_InitArenaPool()
  67. ** again unless PL_FinishArenaPool(pool) has been called.
  68. **/
  69. PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
  70.  
  71. /*
  72. ** Free the arenas in pool and finish using it altogether.
  73. **/
  74. PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
  75.  
  76. /*
  77. ** Compact all of the arenas in a pool so that no space is wasted.
  78. **/
  79. PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
  80.  
  81. /*
  82. ** Friend functions used by the PL_ARENA_*() macros.
  83. **/
  84. PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
  85.  
  86. PR_EXTERN(void *) PL_ArenaGrow(
  87.     PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
  88.  
  89. PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
  90.  
  91. PR_END_EXTERN_C
  92.  
  93. #endif /* defined(PLARENAS_H) */
  94.  
  95. /* plarenas */
  96.