pool.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. typedef struct Pool Pool;
  2. struct Pool {
  3. char* name;
  4. ulong maxsize;
  5. ulong cursize;
  6. ulong curfree;
  7. ulong curalloc;
  8. ulong minarena; /* smallest size of new arena */
  9. ulong quantum; /* allocated blocks should be multiple of */
  10. ulong minblock; /* smallest newly allocated block */
  11. void* freeroot; /* actually Free* */
  12. void* arenalist; /* actually Arena* */
  13. void* (*alloc)(ulong);
  14. int (*merge)(void*, void*);
  15. void (*move)(void* from, void* to);
  16. int flags;
  17. int nfree;
  18. int lastcompact;
  19. void (*lock)(Pool*);
  20. void (*unlock)(Pool*);
  21. void (*print)(Pool*, char*, ...);
  22. void (*panic)(Pool*, char*, ...);
  23. void (*logstack)(Pool*);
  24. void* private;
  25. };
  26. extern void* poolalloc(Pool*, ulong);
  27. extern void poolfree(Pool*, void*);
  28. extern ulong poolmsize(Pool*, void*);
  29. extern void* poolrealloc(Pool*, void*, ulong);
  30. extern void poolcheck(Pool*);
  31. extern int poolcompact(Pool*);
  32. extern void poolblockcheck(Pool*, void*);
  33. extern Pool* mainmem;
  34. extern Pool* imagmem;
  35. enum { /* flags */
  36. POOL_ANTAGONISM = 1<<0,
  37. POOL_PARANOIA = 1<<1,
  38. POOL_VERBOSITY = 1<<2,
  39. POOL_DEBUGGING = 1<<3,
  40. POOL_LOGGING = 1<<4,
  41. POOL_TOLERANCE = 1<<5,
  42. POOL_NOREUSE = 1<<6,
  43. };