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. More... | |
Functions | |
| dbus_bool_t | _dbus_disable_mem_pools (void) |
| Whether to turn off mem pools, useful for leak checking. | |
| void | _dbus_set_fail_alloc_counter (int until_next_fail) |
| Sets the number of allocations until we simulate a failed allocation. | |
| int | _dbus_get_fail_alloc_counter (void) |
| Gets the number of successful allocs until we'll simulate a failed alloc. | |
| void | _dbus_set_fail_alloc_failures (int failures_per_failure) |
| Sets how many mallocs to fail when the fail alloc counter reaches 0. | |
| int | _dbus_get_fail_alloc_failures (void) |
| Gets the number of failures we'll have when the fail malloc counter reaches 0. | |
| 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. | |
| int | _dbus_get_malloc_blocks_outstanding (void) |
| Get the number of outstanding malloc()'d blocks. | |
| 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. | |
| dbus_bool_t | _dbus_memory_test (void) |
| Unit test for DBusMemory. | |
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. | |
Implementation details related to allocating and releasing blocks of memory.
| enum BlockSource |
| 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.
Definition at line 244 of file dbus-memory.c.
References _DBUS_INT_MAX, _dbus_print_backtrace(), FALSE, and TRUE.
Referenced by _dbus_mem_pool_alloc(), dbus_malloc(), dbus_malloc0(), and dbus_realloc().
| dbus_bool_t _dbus_disable_mem_pools | ( | void | ) |
Whether to turn off mem pools, useful for leak checking.
Definition at line 170 of file dbus-memory.c.
Referenced by _dbus_mem_pool_alloc(), and _dbus_mem_pool_dealloc().
| int _dbus_get_fail_alloc_counter | ( | void | ) |
Gets the number of successful allocs until we'll simulate a failed alloc.
Definition at line 203 of file dbus-memory.c.
Referenced by _dbus_mem_pool_alloc(), and _dbus_test_oom_handling().
| int _dbus_get_fail_alloc_failures | ( | void | ) |
Gets the number of failures we'll have when the fail malloc counter reaches 0.
Definition at line 229 of file dbus-memory.c.
| int _dbus_get_malloc_blocks_outstanding | ( | void | ) |
Get the number of outstanding malloc()'d blocks.
Definition at line 284 of file dbus-memory.c.
References DBusAtomic::value.
| dbus_bool_t _dbus_memory_test | ( | void | ) |
Unit test for DBusMemory.
Definition at line 814 of file dbus-memory.c.
References _dbus_assert_not_reached, dbus_free(), dbus_malloc(), dbus_realloc(), NULL, and TRUE.
| 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.
| func | the function | |
| data | data to pass to the function |
Definition at line 716 of file dbus-memory.c.
References _DBUS_LOCK, _DBUS_UNLOCK, ShutdownClosure::data, dbus_new, FALSE, ShutdownClosure::func, ShutdownClosure::next, NULL, and TRUE.
| 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.
| until_next_fail | number of successful allocs before one fails |
Definition at line 185 of file dbus-memory.c.
Referenced by _dbus_mem_pool_alloc(), and _dbus_test_oom_handling().
| void _dbus_set_fail_alloc_failures | ( | int | failures_per_failure | ) |
Sets how many mallocs to fail when the fail alloc counter reaches 0.
| failures_per_failure | number to fail |
Definition at line 217 of file dbus-memory.c.
Referenced by _dbus_test_oom_handling().
| 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 687 of file dbus-memory.c.
Referenced by _dbus_condvar_free_at_location(), _dbus_condvar_new_at_location(), _dbus_connection_close_possibly_shared(), _dbus_connection_new_for_transport(), _dbus_connection_ref_unlocked(), _dbus_get_local_machine_uuid_encoded(), _dbus_mutex_free_at_location(), _dbus_mutex_new_at_location(), dbus_connection_close(), dbus_connection_ref(), dbus_connection_unref(), dbus_message_ref(), dbus_message_unref(), and dbus_threads_init().
1.5.2