| * 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)); \ |
| static void report(const char* name, unsigned int count, size_t size) |
| fprintf(stderr, "%10s: %8u (" SZ_FMT " kB)\n", name, count, size); |
| report(#name, name##_allocs, name##_allocs*sizeof(struct name) >> 10) |