1
0

pool.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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* poolallocalign(Pool*, ulong, ulong, long, ulong);
  28. extern void poolfree(Pool*, void*);
  29. extern ulong poolmsize(Pool*, void*);
  30. extern void* poolrealloc(Pool*, void*, ulong);
  31. extern void poolcheck(Pool*);
  32. extern int poolcompact(Pool*);
  33. extern void poolblockcheck(Pool*, void*);
  34. extern Pool* mainmem;
  35. extern Pool* imagmem;
  36. enum { /* flags */
  37. POOL_ANTAGONISM = 1<<0,
  38. POOL_PARANOIA = 1<<1,
  39. POOL_VERBOSITY = 1<<2,
  40. POOL_DEBUGGING = 1<<3,
  41. POOL_LOGGING = 1<<4,
  42. POOL_TOLERANCE = 1<<5,
  43. POOL_NOREUSE = 1<<6,
  44. };