lib<fancy_memory> 0.1.0
A very simple, very experimental C library for tracking dynamically allocated memory
|
Go to the source code of this file.
Typedefs | |
typedef struct fancy_memory_s | fancy_memory_t |
An opaque data type that is used as a container for storing "memory tracking" related data, and which type gets passed, as a pointer argument, to the library's methods for state interrogation and mutation. | |
Functions | |
void | fancy_memory_get_library_version (uint16_t *major, uint16_t *minor, uint16_t *revision) |
A method that can be used to retrieve the library's current version. It works by populating the arguments major , minor , and revision with the library's major, minor, revision version numbers, respectively. | |
fancy_memory_t * | fancy_memory_create (void) |
The factory method that needs to be used in order to instantiate a fancy_memory_t object. | |
void | fancy_memory_destroy (fancy_memory_t *self) |
The method that should be used to destroy a fancy_memory_t object once that object is no longer needed. | |
void * | fancy_memory_malloc (fancy_memory_t *self, size_t size) |
The method that must be used to allocate and track new memory. | |
void | fancy_memory_free (fancy_memory_t *self, void *pointer) |
The method that must be used to free (and stop tracking) memory previously allocated using the same fancy_memory_t instance (i.e., the object pointed to by self ). | |
void * | fancy_memory_realloc (fancy_memory_t *self, void *pointer, size_t size) |
The method that must be used to reallocate (and update the tracking information of) memory that was initially allocated using the same fancy_memory_t instance (i.e., the object pointed to by self ). | |
void | fancy_memory_debug (fancy_memory_t const *self, FILE *stream) |
A method that can be used to print (i.e., write) a summary of the tracked memory for self . | |
size_t | fancy_memory_get_total (fancy_memory_t const *self) |
The method that must be used to retrieve the total amount of memory (in bytes) currently being tracked by the fancy_memory_t object self . | |
typedef struct fancy_memory_s fancy_memory_t |
An opaque data type that is used as a container for storing "memory tracking" related data, and which type gets passed, as a pointer argument, to the library's methods for state interrogation and mutation.
fancy_memory_t * fancy_memory_create | ( | void | ) |
The factory method that needs to be used in order to instantiate a fancy_memory_t object.
void fancy_memory_debug | ( | fancy_memory_t const * | self, |
FILE * | stream | ||
) |
A method that can be used to print (i.e., write) a summary of the tracked memory for self
.
self | A pointer to the fancy_memory_t instance for which to print a summary. |
stream | A pointer to a writable stream (e.g., stdout , or a file pointer to a text file) to which to print the summary. |
void fancy_memory_destroy | ( | fancy_memory_t * | self | ) |
The method that should be used to destroy a fancy_memory_t object once that object is no longer needed.
self | A pointer to the fancy_memory_t instance to be destroyed. |
void fancy_memory_free | ( | fancy_memory_t * | self, |
void * | pointer | ||
) |
The method that must be used to free (and stop tracking) memory previously allocated using the same fancy_memory_t instance (i.e., the object pointed to by self
).
self | A pointer to the fancy_memory_t instance that was initially used when allocating the memory pointed to by pointer . |
pointer | A pointer to the memory to be freed, which was previously allocated using the fancy_memory_t instance pointed to by self . |
self
will result in the process being terminated. A method that can be used to retrieve the library's current version. It works by populating the arguments major
, minor
, and revision
with the library's major, minor, revision version numbers, respectively.
major | A pointer to a uint16_t value to which the "major" version number will be written. |
minor | A pointer to a uint16_t value to which the "minor" version number will be written. |
revision | A pointer to a uint16_t value to which the "revision" version number will be written. |
size_t fancy_memory_get_total | ( | fancy_memory_t const * | self | ) |
The method that must be used to retrieve the total amount of memory (in bytes) currently being tracked by the fancy_memory_t object self
.
self | A pointer to the fancy_memory_t instance for which to retrieve to total memory usage. |
self
. void * fancy_memory_malloc | ( | fancy_memory_t * | self, |
size_t | size | ||
) |
The method that must be used to allocate and track new memory.
self | A pointer to the fancy_memory_t instance to be used to track the new memory. |
size | The size of the memory to be allocated (and returned). |
void * fancy_memory_realloc | ( | fancy_memory_t * | self, |
void * | pointer, | ||
size_t | size | ||
) |
The method that must be used to reallocate (and update the tracking information of) memory that was initially allocated using the same fancy_memory_t instance (i.e., the object pointed to by self
).
self | A pointer to the fancy_memory_t instance that was used when initially allocating the memory pointed to by pointer . |
pointer | A pointer to the memory to be reallocated, which was initially allocated using the fancy_memory_t instance pointed to by self . |
size | The size to be used for the re-allocation. |
self
will result in the process being terminated.