-#if USEMEMPOOL
-/*
- * This is a small set of memory allocation routines. I created them so
- * that all memory allocation from the kernel takes place at the
- * z_(de)comp_alloc and z_(de)comp_free routines. This eliminates worry
- * about calling valloc() from within an interrupt.
- *
- * The free list is a single linked list sorted by memory address.
- * The zfree() function re-combines any segments it can.
- */
-typedef struct memchunk {
- unsigned int m_size;
- struct memchunk *m_next;
-} MemChunk;
-
-typedef struct {
- void *memHead;
- MemChunk *freePool;
-} MemPool;
-
-static int memPoolAlloc __P((void *arg, unsigned int size));
-static void memPoolFree __P((void *arg));
-
-static int
-memPoolAlloc(arg, size)
-void *arg;
-unsigned int size;
-{
- MemPool **memPool = arg;
- MemChunk *freePool;
-
- if ((*memPool = kmalloc(sizeof(MemPool), GFP_KERNEL)) == NULL) {
- printk(KERN_DEBUG "Unable to allocate Memory Head\n");
- return 0;
- }
-
- if (((*memPool)->memHead = (void *)vmalloc(size)) == NULL) {
- printk(KERN_DEBUG "Unable to allocate Memory Pool\n");
- kfree(*memPool);
- return 0;
- }
- freePool = (*memPool)->freePool = (*memPool)->memHead;
- freePool->m_size = size;
- freePool->m_next = 0;
-
- return 1;
-}
-
-static void
-memPoolFree(arg)
-void *arg;
-{
- MemPool **memPool = arg;
-
- if (*memPool) {
- vfree((*memPool)->memHead);
- kfree(*memPool);
- *memPool = NULL;
- }
-}
-
-#ifdef POOLDGB
-static void showFreeList __P((MemChunk *));
-
-static void
-showFreeList(freePool)
-MemChunk *freePool;
-{
- MemChunk *node;
-
- for (node = freePool; node; node = node->m_next)
- printk(KERN_DEBUG "{%x,%d}->", node, node->m_size);
- printk(KERN_DEBUG "\n");
-}
-#endif
-#endif /* USEMEMPOOL */
-