Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
898 B

  1. /* bufpool.h */
  2. #ifndef BUFPOOL
  3. #define BUFPOOL
  4. #define NBLOCKS 32
  5. typedef enum { is_allocated = 0xf3a1, is_free = 0xf1a2 } Magic;
  6. typedef struct _buffer {
  7. struct _buffer *next; /* next buffer on free list */
  8. } Buffer ;
  9. typedef struct Pool {
  10. Buffer *freelist; /* linked list of free buffers */
  11. char *blocklist[NBLOCKS]; /* blocks of malloced memory */
  12. int nextblock; /* next free block index */
  13. char *curblock; /* last malloced block */
  14. int buffersize; /* bytes per buffer */
  15. int nextsize; /* size of next block of memory */
  16. int nextfree; /* byte offset past next free buffer */
  17. #ifndef NDEBUG
  18. char *name; /* name of the pool */
  19. Magic magic; /* marker for valid pool */
  20. #endif
  21. } Pool;
  22. extern Pool *__gl_new_pool( int, int, char * );
  23. extern char *__gl_new_buffer( Pool * );
  24. extern void __gl_free_buffer( Pool *, void * );
  25. extern void __gl_clear_pool( Pool * );
  26. #endif