Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

walloc.h File Reference


Detailed Description

Explicit-width block allocator, based on zalloc().

Author:
Raphael Manfredi
Date:
2002-2003

#include <glib.h>

Go to the source code of this file.

Defines

#define WFREE_NULL(p, size)

Functions

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().

WARN_UNUSED_RESULT gpointer wcopy (gconstpointer ptr, size_t size)
void wdestroy (void)
 Destroy all the zones we allocated so far.


Define Documentation

#define WFREE_NULL p,
size   ) 
 

Value:

G_STMT_START {              \
    if (p) {                \
        wfree(p,size);      \
        p = NULL;           \
    }                       \
} G_STMT_END


Function Documentation

gpointer walloc size_t  size  ) 
 

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.

Returns:
a pointer to the start of the allocated block.

gpointer walloc0 size_t  size  ) 
 

Same as walloc(), but zeroes the allocated memory before returning.

WARN_UNUSED_RESULT gpointer wcopy gconstpointer  ptr,
size_t  size
[inline, static]
 

void wdestroy void   ) 
 

Destroy all the zones we allocated so far.

void wfree gpointer  ptr,
size_t  size
 

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.

gpointer wrealloc gpointer  old,
size_t  old_size,
size_t  new_size
 

Reallocate a block allocated via walloc().

Returns:
new block address.


Generated on Sun Feb 12 10:50:10 2006 for Gtk-Gnutella by doxygen 1.3.6