Salad  1.0.15
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Macros | Functions
Sld_memory

Macros

#define POOL_GROW_AMOUNT   16
 

Functions

SLD_SSINT sld_memory_pool_init (SLD_USINT initial_size)
 Initialize a memory pool with the specified size. More...
 
SLD_BOOL sld_memory_pool_initialized ()
 Checks whether or not the memory pool is initialized. More...
 
SLD_ULINT sld_memory_pool_size ()
 Returns the size of the memory pool. More...
 
SLD_SSINT sld_memory_pool_resize (SLD_ULINT new_size)
 Resizes the memory pool to the specified size. More...
 
SLD_ULINT sld_memory_pool_add (void *ptr)
 Adds an object to the memory pool. More...
 
SLD_ULINT sld_memory_pool_objects ()
 Returns the total number of objects in the memory pool. More...
 
SLD_ULINT sld_memory_pool_free ()
 Frees any memory allocated for objects stored in the memory pool. More...
 
void sld_memory_pool_nuke ()
 Frees any memory allocated for the initialized memory pool. More...
 

Detailed Description

This module contains functions and macros related to dynamic memory management.

Macro Definition Documentation

#define POOL_GROW_AMOUNT   16

Amount to grow object pool dynamically during add if no free slots remain

Function Documentation

SLD_ULINT sld_memory_pool_add ( void *  ptr)

Adds an object to the memory pool.

Parameters
ptra pointer to the object to be added
Returns
The new total number of objects in the memory pool
sld_memory_pool_add("heap string");
SLD_ULINT sld_memory_pool_free ( )

Frees any memory allocated for objects stored in the memory pool.

Returns
The number of freed objects
printf("%lu objects were freed from the memory pool.\n", sld_memory_pool_free());
Examples:
daemon.c.
SLD_SSINT sld_memory_pool_init ( SLD_USINT  initial_size)

Initialize a memory pool with the specified size.

Parameters
initial_sizeinitial size of the memory pool
Returns
Success or failure
SLD_BOOL sld_memory_pool_initialized ( )

Checks whether or not the memory pool is initialized.

Returns
True or false
void sld_memory_pool_nuke ( )

Frees any memory allocated for the initialized memory pool.

Examples:
daemon.c, list.c, map.c, options.c, queue.c, stack.c, and vector.c.
SLD_ULINT sld_memory_pool_objects ( )

Returns the total number of objects in the memory pool.

Returns
The total number of objects in the memory pool
puts("We can shove more into the memory pool!");
SLD_SSINT sld_memory_pool_resize ( SLD_ULINT  new_size)

Resizes the memory pool to the specified size.

Parameters
new_sizethe new size of the memory pool
Returns
Success or failure
SLD_ULINT sld_memory_pool_size ( )

Returns the size of the memory pool.

Returns
The size of the memory pool
puts("We need to resize the memory pool!");