#include "common.h"
#include "walloc.h"
#include "zalloc.h"
#include "override.h"
Defines | |
#define | WALLOC_MAX 4096 /**< Passed this size, use malloc() */ |
Passed this size, use malloc(). | |
#define | WALLOC_CHUNK 4096 /**< Target chunk size for small structs */ |
Target chunk size for small structs. | |
#define | WALLOC_MINCOUNT 8 /**< Minimum amount of structs in a chunk */ |
Minimum amount of structs in a chunk. | |
#define | WZONE_SIZE (WALLOC_MAX / ZALLOC_ALIGNBYTES) |
Functions | |
RCSID ("$Id:walloc.c, v 1.8 2005/09/26 16:51:29 cbiere Exp $") | |
gpointer | walloc (size_t size) |
Allocate memory from a zone suitable for the given size. | |
gpointer | walloc0 (size_t size) |
Same as walloc(), but zeroes the allocated memory before returning. | |
void | wfree (gpointer ptr, size_t size) |
Free a block allocated via walloc(). | |
gpointer | wrealloc (gpointer old, size_t old_size, size_t new_size) |
Reallocate a block allocated via walloc(). | |
void | wdestroy (void) |
Destroy all the zones we allocated so far. | |
Variables | |
zone * | wzone [WZONE_SIZE] |
|
Target chunk size for small structs.
|
|
Passed this size, use malloc().
|
|
Minimum amount of structs in a chunk.
|
|
|
|
|
|
Allocate memory from a zone suitable for the given size. The basics for this algorithm is to allocate from fixed-sized zones, which are multiples of ZALLOC_ALIGNBYTES until WALLOC_MAX (e.g. 8, 16, 24, 40, ...) and to malloc() if size is greater or equal to WALLOC_MAX. Naturally, zones are allocated on demand only.
|
|
Same as walloc(), but zeroes the allocated memory before returning.
|
|
Destroy all the zones we allocated so far.
|
|
Free a block allocated via walloc(). The size is used to find the zone from which the block was allocated, or to determine that we actually malloc()'ed it so it gets free()'ed. |
|
Reallocate a block allocated via walloc().
|
|
|