]> mj.ucw.cz Git - libucw.git/blobdiff - lib/pools.h
Allow locked dirty pages. Better debugging. Simplified and cleaned up
[libucw.git] / lib / pools.h
index 861cf82a241e58fda46407d5fe649a926e0eb747..54658cf7043d532f1c6604123e0a400db994fd16 100644 (file)
@@ -1,24 +1,28 @@
 /*
  *     Sherlock Library -- Memory Pools
  *
- *     (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  */
 
-#define POOL_ALIGN 4
+#ifndef POOL_ALIGN
+#define POOL_ALIGN CPU_STRUCT_ALIGN
+#endif
 
 struct mempool {
-  struct memchunk *chunks;
   byte *free, *last;
+  struct memchunk *first, *current, **plast;
+  struct memchunk *first_large;
   uns chunk_size, threshold;
 };
 
 struct mempool *new_pool(uns);
 void free_pool(struct mempool *);
+void flush_pool(struct mempool *);
 void *pool_alloc(struct mempool *, uns);
 
 extern inline void *fast_alloc(struct mempool *p, uns l)
 {
-  void *f = (void *) (((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1));
+  byte *f = (void *) (((uns) p->free + POOL_ALIGN - 1) & ~(POOL_ALIGN - 1));
   byte *ee = f + l;
   if (ee > p->last)
     return pool_alloc(p, l);
@@ -28,7 +32,7 @@ extern inline void *fast_alloc(struct mempool *p, uns l)
 
 extern inline void *fast_alloc_noalign(struct mempool *p, uns l)
 {
-  void *f = p->free;
+  byte *f = p->free;
   byte *ee = f + l;
   if (ee > p->last)
     return pool_alloc(p, l);