| * alloc.c - specialized allocator for internal objects |
| * Copyright (C) 2006 Linus Torvalds |
| * The standard malloc/free wastes too much space for objects, partly because |
| * it maintains all the allocation infrastructure (which isn't needed, since |
| * we never free an object descriptor anyway), but even more because it ends |
| * up with maximal alignment because it doesn't know what the object alignment |
| * for the new allocation is. |
| #define DEFINE_ALLOCATOR(name) \ |
| static unsigned int name##_allocs; \ |
| struct name *alloc_##name##_node(void) \ |
| static struct name *block; \ |
| block = xcalloc(BLOCKING, sizeof(struct name)); \ |
| fprintf(stderr, "%10s: %8u (%zu kB)\n", #name, name##_allocs, name##_allocs*sizeof(struct name) >> 10) |