Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

Memory allocation implementation details
[D-BUS internal implementation details]

internals of dbus_malloc() etc. More...

Data Structures

struct  ShutdownClosure
 This struct represents a function to be called on shutdown. More...


Defines

#define GUARD_VALUE   0xdeadbeef
 value stored in guard padding for debugging buffer overrun.

#define GUARD_INFO_SIZE   8
 size of the information about the block stored in guard mode.

#define GUARD_START_PAD   16
 size of the GUARD_VALUE-filled padding after the header info.

#define GUARD_END_PAD   16
 size of the GUARD_VALUE-filled padding at the end of the block.

#define GUARD_START_OFFSET   (GUARD_START_PAD + GUARD_INFO_SIZE)
 size of stuff at start of block.

#define GUARD_EXTRA_SIZE   (GUARD_START_OFFSET + GUARD_END_PAD)
 total extra size over the requested allocation for guard stuff.


Typedefs

typedef ShutdownClosure ShutdownClosure
 Represents a function to be called on shutdown.


Enumerations

enum  BlockSource {
  SOURCE_UNKNOWN, SOURCE_MALLOC, SOURCE_REALLOC, SOURCE_MALLOC_ZERO,
  SOURCE_REALLOC_NULL
}
 Where the block came from.


Functions

dbus_bool_t _dbus_disable_mem_pools (void)
 Whether to turn off mem pools, useful for leak checking. More...

void _dbus_set_fail_alloc_counter (int until_next_fail)
 Sets the number of allocations until we simulate a failed allocation. More...

int _dbus_get_fail_alloc_counter (void)
 Gets the number of successful allocs until we'll simulate a failed alloc. More...

void _dbus_set_fail_alloc_failures (int failures_per_failure)
 Sets how many mallocs to fail when the fail alloc counter reaches 0. More...

int _dbus_get_fail_alloc_failures (void)
 Gets the number of failures we'll have when the fail malloc counter reaches 0. More...

dbus_bool_t _dbus_decrement_fail_alloc_counter (void)
 Called when about to alloc some memory; if it returns TRUE, then the allocation should fail. More...

int _dbus_get_malloc_blocks_outstanding (void)
 Get the number of outstanding malloc()'d blocks. More...

dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction function, void *data)
 Register a cleanup function to be called exactly once the next time dbus_shutdown() is called. More...

dbus_bool_t _dbus_memory_test (void)

Variables

int _dbus_current_generation = 1
 _dbus_current_generation is used to track each time that dbus_shutdown() is called, so we can reinit things after it's been called. More...


Detailed Description

internals of dbus_malloc() etc.

Implementation details related to allocating and releasing blocks of memory.


Function Documentation

dbus_bool_t _dbus_decrement_fail_alloc_counter void   
 

Called when about to alloc some memory; if it returns TRUE, then the allocation should fail.

If it returns FALSE, then the allocation should not fail.

Returns:
TRUE if this alloc should fail

Definition at line 243 of file dbus-memory.c.

dbus_bool_t _dbus_disable_mem_pools void   
 

Whether to turn off mem pools, useful for leak checking.

Returns:
TRUE if mempools should not be used.

Definition at line 170 of file dbus-memory.c.

int _dbus_get_fail_alloc_counter void   
 

Gets the number of successful allocs until we'll simulate a failed alloc.

Returns:
current counter value

Definition at line 203 of file dbus-memory.c.

int _dbus_get_fail_alloc_failures void   
 

Gets the number of failures we'll have when the fail malloc counter reaches 0.

Returns:
number of failures planned

Definition at line 229 of file dbus-memory.c.

int _dbus_get_malloc_blocks_outstanding void   
 

Get the number of outstanding malloc()'d blocks.

Returns:
number of blocks

Definition at line 282 of file dbus-memory.c.

dbus_bool_t _dbus_memory_test void   
 

Unit test for DBusMemory

Returns:
TRUE on success.

Definition at line 777 of file dbus-memory.c.

dbus_bool_t _dbus_register_shutdown_func DBusShutdownFunction    func,
void *    data
 

Register a cleanup function to be called exactly once the next time dbus_shutdown() is called.

Parameters:
func  the function
data  data to pass to the function
Returns:
FALSE on not enough memory

Definition at line 704 of file dbus-memory.c.

References ShutdownClosure::data, ShutdownClosure::func, and ShutdownClosure::next.

void _dbus_set_fail_alloc_counter int    until_next_fail
 

Sets the number of allocations until we simulate a failed allocation.

If set to 0, the next allocation to run fails; if set to 1, one succeeds then the next fails; etc. Set to _DBUS_INT_MAX to not fail anything.

Parameters:
until_next_fail  number of successful allocs before one fails

Definition at line 185 of file dbus-memory.c.

void _dbus_set_fail_alloc_failures int    failures_per_failure
 

Sets how many mallocs to fail when the fail alloc counter reaches 0.

Parameters:
failures_per_failure  number to fail

Definition at line 217 of file dbus-memory.c.


Variable Documentation

int _dbus_current_generation = 1
 

_dbus_current_generation is used to track each time that dbus_shutdown() is called, so we can reinit things after it's been called.

It is simply incremented each time we shut down.

Definition at line 675 of file dbus-memory.c.


Generated on Wed Jun 9 05:01:28 2004 for D-BUS by doxygen1.2.15