koliseo 0.4.9
|
#include "koliseo.h"
Go to the source code of this file.
Functions | |
const char * | string_koliseo_version (void) |
Returns the constant string representing current version for Koliseo. | |
int | int_koliseo_version (void) |
Returns the constant int representing current version for Koliseo. | |
void | KLS_OOM_default_handler__ (Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count) |
Used internally for handling Out-Of-Memory in push calls when no user handler is provided. | |
void | KLS_PTRDIFF_MAX_default_handler__ (struct Koliseo *kls, ptrdiff_t size, ptrdiff_t count) |
void | KLS_ZEROCOUNT_default_handler__ (Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size) |
Used internally for handling zero-count in push calls when no user handler is provided. | |
KLS_Conf | kls_conf_init_handled (int autoset_regions, int alloc_backend, ptrdiff_t reglist_kls_size, int autoset_temp_regions, int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, FILE *log_fp, const char *log_filepath, KLS_Err_Handlers err_handlers) |
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS. | |
KLS_Conf | kls_conf_init (int autoset_regions, int alloc_backend, ptrdiff_t reglist_kls_size, int autoset_temp_regions, int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, FILE *log_fp, const char *log_filepath) |
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS. | |
void | kls_dbg_features (void) |
Prints enabled Koliseo features to stderr. | |
ptrdiff_t | kls_get_pos (const Koliseo *kls) |
Returns the current offset (position of pointer bumper) for the passed Koliseo. | |
void | kls_log (Koliseo *kls, const char *tag, const char *format,...) |
Logs a message to the log_fp FILE field of the passed Koliseo pointer, if its conf.kls_verbose_lvl is >0. | |
Koliseo * | kls_new_alloc_ext (ptrdiff_t size, kls_alloc_func alloc_func, KLS_Hooks ext_handlers, void *user) |
Takes a ptrdiff_t size and a function pointer to the allocation function. | |
Koliseo * | kls_new_alloc (ptrdiff_t size, kls_alloc_func alloc_func) |
Takes a ptrdiff_t size and a function pointer to the allocation function. | |
Koliseo * | kls_new_conf_alloc_ext (ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, KLS_Hooks ext_handlers, void *user) |
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, and an allocation function pointer. | |
Koliseo * | kls_new_conf_alloc (ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func) |
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, and an allocation function pointer. | |
Koliseo * | kls_new_traced_alloc_handled (ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, KLS_Err_Handlers err_handlers) |
Takes a ptrdiff_t size, a filepath for the trace output file, and an allocation function pointer. | |
Koliseo * | kls_new_traced_alloc (ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func) |
Takes a ptrdiff_t size, a filepath for the trace output file, and an allocation function pointer. | |
Koliseo * | kls_new_dbg_alloc_handled (ptrdiff_t size, kls_alloc_func alloc_func, KLS_Err_Handlers err_handlers) |
Takes a ptrdiff_t size and an allocation function pointer, and returns a pointer to the prepared Koliseo. | |
Koliseo * | kls_new_dbg_alloc (ptrdiff_t size, kls_alloc_func alloc_func) |
Takes a ptrdiff_t size and an allocation function pointer, and returns a pointer to the prepared Koliseo. | |
int | kls__check_available_failable (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, const char *caller_name) |
Takes a Koliseo, a ptrdiff_t size, align and count, and a caller name. | |
void * | kls_push (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count. | |
void * | kls_push_zero (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count. | |
void * | kls_push_zero_ext (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count. | |
void * | kls_temp_push_zero_ext (Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count. | |
void | print_kls_2file (FILE *fp, const Koliseo *kls) |
Prints header fields from the passed Koliseo pointer, to the passed FILE pointer. | |
void | print_dbg_kls (const Koliseo *kls) |
Prints header fields from the passed Koliseo pointer, to stderr. | |
void | print_temp_kls_2file (FILE *fp, const Koliseo_Temp *t_kls) |
Prints header fields from the passed Koliseo_Temp pointer, to the passed FILE pointer. | |
void | print_dbg_temp_kls (const Koliseo_Temp *t_kls) |
Prints header fields from the passed Koliseo_Temp pointer, to stderr. | |
void | kls_formatSize (ptrdiff_t size, char *outputBuffer, size_t bufferSize) |
Converts a ptrdiff_t size to human-readable SI units (modulo 1000). | |
void | kls_clear (Koliseo *kls) |
Resets the offset field for the passed Koliseo pointer. | |
void | kls_free (Koliseo *kls) |
Calls kls_clear() on the passed Koliseo pointer and the frees the actual Koliseo. | |
Koliseo_Temp * | kls_temp_start (Koliseo *kls) |
Starts a new savestate for the passed Koliseo pointer, by initialising its Koliseo_Temp pointer and returning it. | |
void | kls_temp_end (Koliseo_Temp *tmp_kls) |
Ends passed Koliseo_Temp pointer. | |
void * | kls_pop (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count. | |
void * | kls_pop_AR (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count. | |
void * | kls_temp_pop (Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count. | |
void * | kls_temp_pop_AR (Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count) |
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count. | |
char * | kls_strdup (Koliseo *kls, char *source) |
Function to dupe a C string to a Koliseo, and return a pointer to the allocated string. | |
char ** | kls_strdup_arr (Koliseo *kls, size_t count, char **source) |
Function to dupe a C string array to a Koliseo, and return a pointer to the allocated array. | |
char * | kls_t_strdup (Koliseo_Temp *t_kls, char *source) |
Function to dupe a C string to a Koliseo_Temp, and return a pointer to the allocated string. | |
char ** | kls_t_strdup_arr (Koliseo_Temp *t_kls, size_t count, char **source) |
Function to dupe a C string array to a Koliseo_Temp, and return a pointer to the allocated array. |
Variables | |
KLS_Conf | KLS_DEFAULT_CONF |
Config used by any new Koliseo by default. | |
KLS_Stats | KLS_STATS_DEFAULT |
int int_koliseo_version | ( | void | ) |
Returns the constant int representing current version for Koliseo.
int kls__check_available_failable | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count, | ||
const char * | caller_name ) |
Takes a Koliseo, a ptrdiff_t size, align and count, and a caller name.
Checks if the passed Koliseo can fit the requested allocation. In case of errors, tries calling the appropriate handler.
kls | The Koliseo to check space for. |
size | The size of the type to allocate. |
align | The alignment of the type to allocate. |
count | The count of allocations. |
caller_name | Name for caller. Used for error reporting. |
void kls_clear | ( | Koliseo * | kls | ) |
Resets the offset field for the passed Koliseo pointer.
Notably, it sets the prev_offset field to the previous offset, thus remembering where last allocation was before the clear.
kls | The Koliseo at hand. |
KLS_Conf kls_conf_init | ( | int | autoset_regions, |
int | alloc_backend, | ||
ptrdiff_t | reglist_kls_size, | ||
int | autoset_temp_regions, | ||
int | collect_stats, | ||
int | verbose_lvl, | ||
int | block_while_has_temp, | ||
int | allow_zerocount_push, | ||
FILE * | log_fp, | ||
const char * | log_filepath ) |
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS.
KLS_Conf kls_conf_init_handled | ( | int | autoset_regions, |
int | alloc_backend, | ||
ptrdiff_t | reglist_kls_size, | ||
int | autoset_temp_regions, | ||
int | collect_stats, | ||
int | verbose_lvl, | ||
int | block_while_has_temp, | ||
int | allow_zerocount_push, | ||
FILE * | log_fp, | ||
const char * | log_filepath, | ||
KLS_Err_Handlers | err_handlers ) |
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS.
Passes custom error handlers for errors in push calls.
void kls_dbg_features | ( | void | ) |
Prints enabled Koliseo features to stderr.
void kls_formatSize | ( | ptrdiff_t | size, |
char * | outputBuffer, | ||
size_t | bufferSize ) |
Converts a ptrdiff_t size to human-readable SI units (modulo 1000).
Fills outputBuffer with the converted string.
size | The size at hand. |
outputBuffer | The output buffer. |
bufferSize | The output buffer size. |
void kls_free | ( | Koliseo * | kls | ) |
Calls kls_clear() on the passed Koliseo pointer and the frees the actual Koliseo.
kls | The Koliseo at hand. |
ptrdiff_t kls_get_pos | ( | const Koliseo * | kls | ) |
Returns the current offset (position of pointer bumper) for the passed Koliseo.
kls | The Koliseo at hand. |
void kls_log | ( | Koliseo * | kls, |
const char * | tag, | ||
const char * | format, | ||
... ) |
Logs a message to the log_fp FILE field of the passed Koliseo pointer, if its conf.kls_verbose_lvl is >0.
kls | The Koliseo pointer hosting the log_fp FILE pointer. |
tag | Tag for a message. |
format | The message format string. |
Koliseo * kls_new_alloc | ( | ptrdiff_t | size, |
kls_alloc_func | alloc_func ) |
Takes a ptrdiff_t size and a function pointer to the allocation function.
Allocates the backing memory for a Koliseo. Sets the KLS_Conf field to KLS_DEFAULT_CONF. Sets the fields with appropriate values if memory allocation was successful, goes to exit() otherwise.
size | The size for Koliseo data field. |
alloc_func | The allocation function to use to init the Koliseo. |
Koliseo * kls_new_alloc_ext | ( | ptrdiff_t | size, |
kls_alloc_func | alloc_func, | ||
KLS_Hooks | ext_handlers, | ||
void * | user ) |
Takes a ptrdiff_t size and a function pointer to the allocation function.
Additional arguments are for extensions. Allocates the backing memory for a Koliseo. Sets the KLS_Conf field to KLS_DEFAULT_CONF. Sets the fields with appropriate values if memory allocation was successful, goes to exit() otherwise.
size | The size for Koliseo data field. |
alloc_func | The allocation function to use to init the Koliseo. |
Koliseo * kls_new_conf_alloc | ( | ptrdiff_t | size, |
KLS_Conf | conf, | ||
kls_alloc_func | alloc_func ) |
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, and an allocation function pointer.
Additional arguments are for extensions. Calls kls_new_alloc() to initialise the Koliseo, then calls kls_set_conf() to update the config. Returns the new Koliseo.
size | The size for Koliseo data field. |
conf | The KLS_Conf for the new Koliseo. |
alloc_func | The allocation function to use. |
Koliseo * kls_new_conf_alloc_ext | ( | ptrdiff_t | size, |
KLS_Conf | conf, | ||
kls_alloc_func | alloc_func, | ||
KLS_Hooks | ext_handlers, | ||
void * | user ) |
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, and an allocation function pointer.
Additional arguments are for extensions. Calls kls_new_alloc() to initialise the Koliseo, then calls kls_set_conf() to update the config. Returns the new Koliseo.
size | The size for Koliseo data field. |
conf | The KLS_Conf for the new Koliseo. |
alloc_func | The allocation function to use. |
Koliseo * kls_new_dbg_alloc | ( | ptrdiff_t | size, |
kls_alloc_func | alloc_func ) |
Takes a ptrdiff_t size and an allocation function pointer, and returns a pointer to the prepared Koliseo.
Calls kls_new_conf_alloc() to initialise the Koliseo with the proper config for a debug Koliseo (printing to stderr).
size | The size for Koliseo data field. |
alloc_func | The allocation function to use. |
Koliseo * kls_new_dbg_alloc_handled | ( | ptrdiff_t | size, |
kls_alloc_func | alloc_func, | ||
KLS_Err_Handlers | err_handlers ) |
Takes a ptrdiff_t size and an allocation function pointer, and returns a pointer to the prepared Koliseo.
Calls kls_new_conf_alloc() to initialise the Koliseo with the proper config for a debug Koliseo (printing to stderr).
size | The size for Koliseo data field. |
alloc_func | The allocation function to use. |
err_handlers | The error handlers for errors in push calls. |
Koliseo * kls_new_traced_alloc | ( | ptrdiff_t | size, |
const char * | output_path, | ||
kls_alloc_func | alloc_func ) |
Takes a ptrdiff_t size, a filepath for the trace output file, and an allocation function pointer.
Returns a pointer to the prepared Koliseo. Calls kls_new_conf_alloc() to initialise the Koliseo with the proper config for a traced Koliseo, logging to the passed filepath.
size | The size for Koliseo data field. |
output_path | The filepath for log output. |
alloc_func | The allocation function to use. |
Koliseo * kls_new_traced_alloc_handled | ( | ptrdiff_t | size, |
const char * | output_path, | ||
kls_alloc_func | alloc_func, | ||
KLS_Err_Handlers | err_handlers ) |
Takes a ptrdiff_t size, a filepath for the trace output file, and an allocation function pointer.
Returns a pointer to the prepared Koliseo. Calls kls_new_conf_alloc() to initialise the Koliseo with the proper config for a traced Koliseo, logging to the passed filepath.
size | The size for Koliseo data field. |
output_path | The filepath for log output. |
alloc_func | The allocation function to use. |
err_handlers | The error handlers struct for errors in push calls. |
void KLS_OOM_default_handler__ | ( | Koliseo * | kls, |
ptrdiff_t | available, | ||
ptrdiff_t | padding, | ||
ptrdiff_t | size, | ||
ptrdiff_t | count ) |
Used internally for handling Out-Of-Memory in push calls when no user handler is provided.
kls | The Koliseo used in the push call |
available | The Koliseo's available memory |
padding | The current push call's padding |
size | The current push call's size |
count | The current push call's count |
void * kls_pop | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Tries popping the specified amount of memory from the Koliseo data field, marking it as free (as far as Koliseo is concerned), or goes to exit() if the operation fails.
kls | The Koliseo at hand. |
size | The size for data to pop. |
align | The alignment for data to pop. |
count | The multiplicative quantity to scale data size to pop for. |
void * kls_pop_AR | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Tries popping the specified amount of memory from the Koliseo data field, marking it as free (as far as Koliseo is concerned), or goes to exit() if the operation fails.
kls | The Koliseo at hand. |
size | The size for data to pop. |
align | The alignment for data to pop. |
count | The multiplicative quantity to scale data size to pop for. |
void KLS_PTRDIFF_MAX_default_handler__ | ( | struct Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | count ) |
void * kls_push | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Tries pushing the specified amount of memory to the Koliseo data field, or goes to exit() if the operation fails. Notably, it does NOT zero the memory region.
kls | The Koliseo at hand. |
size | The size for data to push. |
align | The alignment for data to push. |
count | The multiplicative quantity to scale data size to push for. |
void * kls_push_zero | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Tries pushing the specified amount of memory to the Koliseo data field, or goes to exit() if the operation fails. Notably, it zeroes the memory region.
kls | The Koliseo at hand. |
size | The size for data to push. |
align | The alignment for data to push. |
count | The multiplicative quantity to scale data size to push for. |
void * kls_push_zero_ext | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Tries pushing the specified amount of memory to the Koliseo data field, or goes to exit() if the operation fails. Notably, it zeroes the memory region.
kls | The Koliseo at hand. |
size | The size for data to push. |
align | The alignment for data to push. |
count | The multiplicative quantity to scale data size to push for. |
char * kls_strdup | ( | Koliseo * | kls, |
char * | source ) |
Function to dupe a C string to a Koliseo, and return a pointer to the allocated string.
Unsafe, do not use.
char ** kls_strdup_arr | ( | Koliseo * | kls, |
size_t | count, | ||
char ** | source ) |
Function to dupe a C string array to a Koliseo, and return a pointer to the allocated array.
Unsafe, do not use.
char * kls_t_strdup | ( | Koliseo_Temp * | t_kls, |
char * | source ) |
Function to dupe a C string to a Koliseo_Temp, and return a pointer to the allocated string.
Unsafe, do not use.
char ** kls_t_strdup_arr | ( | Koliseo_Temp * | t_kls, |
size_t | count, | ||
char ** | source ) |
Function to dupe a C string array to a Koliseo_Temp, and return a pointer to the allocated array.
Unsafe, do not use.
void kls_temp_end | ( | Koliseo_Temp * | tmp_kls | ) |
Ends passed Koliseo_Temp pointer.
tmp_kls | The Koliseo_Temp at hand. |
void * kls_temp_pop | ( | Koliseo_Temp * | t_kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Tries popping the specified amount of memory from the Koliseo data field, marking it as free (as far as Koliseo is concerned), or goes to exit() if the operation fails.
t_kls | The Koliseo_Temp at hand. |
size | The size for data to pop. |
align | The alignment for data to pop. |
count | The multiplicative quantity to scale data size to pop for. |
void * kls_temp_pop_AR | ( | Koliseo_Temp * | t_kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Tries popping the specified amount of memory from the Koliseo data field, marking it as free (as far as Koliseo is concerned), or goes to exit() if the operation fails.
t_kls | The Koliseo_Temp at hand. |
size | The size for data to pop. |
align | The alignment for data to pop. |
count | The multiplicative quantity to scale data size to pop for. |
void * kls_temp_push_zero_ext | ( | Koliseo_Temp * | t_kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count ) |
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Tries pushing the specified amount of memory to the referred Koliseo data field, or goes to exit() if the operation fails. Notably, it zeroes the memory region. Will be removed in 0.6, leaving kls_temp_push_zero_ext() as its replacement.
t_kls | The Koliseo_Temp at hand. |
size | The size for data to push. |
align | The alignment for data to push. |
count | The multiplicative quantity to scale data size to push for. |
Koliseo_Temp * kls_temp_start | ( | Koliseo * | kls | ) |
Starts a new savestate for the passed Koliseo pointer, by initialising its Koliseo_Temp pointer and returning it.
Notably, you should not use the original while using the copy.
kls | The Koliseo at hand. |
void KLS_ZEROCOUNT_default_handler__ | ( | Koliseo * | kls, |
ptrdiff_t | available, | ||
ptrdiff_t | padding, | ||
ptrdiff_t | size ) |
Used internally for handling zero-count in push calls when no user handler is provided.
By default, it goes to exit().
kls | The Koliseo used in the push call |
available | The Koliseo's available memory |
padding | The current push call's padding |
size | The current push call's size |
void print_dbg_kls | ( | const Koliseo * | kls | ) |
Prints header fields from the passed Koliseo pointer, to stderr.
kls | The Koliseo at hand. |
void print_dbg_temp_kls | ( | const Koliseo_Temp * | t_kls | ) |
Prints header fields from the passed Koliseo_Temp pointer, to stderr.
t_kls | The Koliseo_Temp at hand. |
void print_kls_2file | ( | FILE * | fp, |
const Koliseo * | kls ) |
Prints header fields from the passed Koliseo pointer, to the passed FILE pointer.
fp | The FILE pointer to print to. |
kls | The Koliseo at hand. |
void print_temp_kls_2file | ( | FILE * | fp, |
const Koliseo_Temp * | t_kls ) |
Prints header fields from the passed Koliseo_Temp pointer, to the passed FILE pointer.
fp | The FILE pointer to print to. |
t_kls | The Koliseo_Temp at hand. |
const char * string_koliseo_version | ( | void | ) |
Returns the constant string representing current version for Koliseo.
KLS_Conf KLS_DEFAULT_CONF |
Config used by any new Koliseo by default.
KLS_Stats KLS_STATS_DEFAULT |