This file is a wrapper for all heap-related operations. More...
Go to the source code of this file.
Data Structures | |
struct | heap_stats_t |
Container for storing a heap user's usage statistics. More... | |
Functions | |
void | heap_reset () |
Resets the heap functionality. More... | |
bool | heap_create_hid (char *a_name, heap_id_t *a_heap_id) |
Create a new heap ID. More... | |
bool | heap_stats (heap_id_t a_heap_id, heap_stats_t *a_heap_stats) |
Get heap statistics for the given heap user. More... | |
void | heap_totals (heap_stats_t *a_heap_totals) |
Get overall heap statistics. More... | |
void * | heap_malloc (heap_id_t a_id, size_t a_size) |
Allocate a_size bytes of heap memory for the given heap user. More... | |
void * | heap_calloc (heap_id_t a_id, size_t a_nr_elements, size_t a_size) |
Allocate heap memory for an array of elements. More... | |
void * | heap_realloc (void *a_ptr, size_t a_size) |
Re-allocate memory for the given object. More... | |
void | heap_free (void *a_ptr) |
Free the memory occupied by the given object. More... | |
size_t | heap_sizeof (void *a_ptr) |
Get the size of the given object. More... | |
heap_id_t | heap_get_id (void *a_ptr) |
Get heap ID of object. More... | |
void | heap_transfer_owner (void *a_ptr, heap_id_t a_id) |
Transfer ownership of an object. More... | |
This file is a wrapper for all heap-related operations.
It collects heap memory usage statistics for a software component. This may be useful when tracing back problems to memory leaks.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
Verify functioning of this component.
Add an example of use to the Doxygen documentation
Definition in file glm_heap.h.
void* heap_calloc | ( | heap_id_t | a_id, |
size_t | a_nr_elements, | ||
size_t | a_size | ||
) |
Allocate heap memory for an array of elements.
a_id | Heap-ID |
a_nr_elements | Size of the array |
a_size | Size of a single array element |
Definition at line 151 of file glm_heap.c.
bool heap_create_hid | ( | char * | a_name, |
heap_id_t * | a_heap_id | ||
) |
Create a new heap ID.
a_name | Pointer to the start of the name name of the calling software component. Make sure the name is '\0'- terminated! |
a_heap_id | Pointer to variable to which the created heap-ID is to be stored. |
Definition at line 62 of file glm_heap.c.
void heap_free | ( | void * | a_ptr) |
Free the memory occupied by the given object.
a_ptr | Pointer to the object to be freed. |
Definition at line 228 of file glm_heap.c.
heap_id_t heap_get_id | ( | void * | a_ptr) |
Get heap ID of object.
a_ptr | Pointer to object which heap ID is requested. |
Definition at line 260 of file glm_heap.c.
void* heap_malloc | ( | heap_id_t | a_id, |
size_t | a_size | ||
) |
Allocate a_size bytes of heap memory for the given heap user.
a_id | Heap-ID |
a_size | Number of bytes to allocate. |
Definition at line 118 of file glm_heap.c.
void* heap_realloc | ( | void * | a_ptr, |
size_t | a_size | ||
) |
Re-allocate memory for the given object.
a_ptr | Pointer to the object to be reallocated. |
a_size | Requested new size. If size is 0, all memory will be freed. If size is equal to the current size, no action is taken. |
Definition at line 177 of file glm_heap.c.
void heap_reset | ( | ) |
Resets the heap functionality.
All registered heap-ID's will be unregistered and their statistics will be cleared.
Definition at line 51 of file glm_heap.c.
size_t heap_sizeof | ( | void * | a_ptr) |
Get the size of the given object.
a_ptr | Pointer to the object |
Definition at line 249 of file glm_heap.c.
bool heap_stats | ( | heap_id_t | a_heap_id, |
heap_stats_t * | a_heap_stats | ||
) |
Get heap statistics for the given heap user.
a_heap_id | The caller's heap-ID. |
a_heap_stats | Pointer to variable to which to store a copy of the heap statistics. |
Definition at line 94 of file glm_heap.c.
void heap_totals | ( | heap_stats_t * | a_heap_totals) |
Get overall heap statistics.
a_heap_totals | Pointer to variable in which to store copy of the overall heap statistics. |
Definition at line 110 of file glm_heap.c.
void heap_transfer_owner | ( | void * | a_ptr, |
heap_id_t | a_id | ||
) |
Transfer ownership of an object.
Changes the heap ID of the given object to an other heap ID.
a_ptr | Pointer to the object. |
a_id | Heap ID to be given to the object. |
Definition at line 271 of file glm_heap.c.