koliseo 0.4.6
|
#include "koliseo.h"
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. | |
const char * | kls_reglist_backend_string (KLS_RegList_Alloc_Backend kls_be) |
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) |
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, 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, 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. | |
int | kls_get_maxRegions_KLS_BASIC (Koliseo *kls) |
Calcs the max number of possible KLS_PUSH ops when using KLS_BASIC reglist alloc backend. | |
int | kls_temp_get_maxRegions_KLS_BASIC (Koliseo_Temp *t_kls) |
Calcs the max number of possible KLS_PUSH_T ops when using KLS_BASIC reglist alloc backend. | |
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 (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 (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. | |
Koliseo * | kls_new_traced_AR_KLS_alloc_handled (ptrdiff_t size, const char *output_path, ptrdiff_t reglist_kls_size, kls_alloc_func alloc_func, KLS_Err_Handlers err_handlers) |
Takes a ptrdiff_t size and a filepath for the trace output file, and the needed parameters for a successful init of the prepared Koliseo. | |
Koliseo * | kls_new_traced_AR_KLS_alloc (ptrdiff_t size, const char *output_path, ptrdiff_t reglist_kls_size, kls_alloc_func alloc_func) |
Takes a ptrdiff_t size and a filepath for the trace output file, and the needed parameters for a successful init of the prepared Koliseo. | |
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_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_push_zero_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. | |
void * | kls_push_zero_named (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, char *name, char *desc) |
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count. | |
void * | kls_temp_push_zero_named (Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, char *name, char *desc) |
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count. | |
void * | kls_push_zero_typed (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, int type, char *name, char *desc) |
Takes a Koliseo pointer, a KLS_Region_Type index, and ptrdiff_t values for size, align and count. | |
void * | kls_temp_push_zero_typed (Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, int type, char *name, char *desc) |
Takes a Koliseo_Temp, a KLS_Region_Type index, 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. | |
bool | kls_temp_set_conf (Koliseo_Temp *t_kls, KLS_Temp_Conf conf) |
Updates the KLS_Temp_Conf for the passed Koliseo_Temp pointer. | |
void | kls_temp_end (Koliseo_Temp *tmp_kls) |
Ends passed Koliseo_Temp pointer. | |
KLS_Region_List | kls_rl_emptyList (void) |
bool | kls_rl_empty (KLS_Region_List l) |
KLS_list_element | kls_rl_head (KLS_Region_List l) |
KLS_Region_List | kls_rl_tail (KLS_Region_List l) |
KLS_Region_List | kls_rl_cons (Koliseo *kls, KLS_list_element e, KLS_Region_List l) |
KLS_region_list_item * | kls_list_pop (Koliseo *kls) |
KLS_Region_List | kls_rl_t_cons (Koliseo_Temp *t_kls, KLS_list_element e, KLS_Region_List l) |
KLS_region_list_item * | kls_t_list_pop (Koliseo_Temp *t_kls) |
void | kls_rl_freeList (KLS_Region_List l) |
Frees all values and nodes for passed Region list. | |
void | kls_rl_showList_toFile (KLS_Region_List l, FILE *fp) |
void | kls_rl_showList (KLS_Region_List l) |
bool | kls_rl_member (KLS_list_element el, KLS_Region_List l) |
int | kls_rl_length (KLS_Region_List l) |
KLS_Region_List | kls_rl_append (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2) |
KLS_Region_List | kls_rl_reverse (Koliseo *kls, KLS_Region_List l) |
KLS_Region_List | kls_rl_copy (Koliseo *kls, KLS_Region_List l) |
KLS_Region_List | kls_rl_delete (Koliseo *kls, KLS_list_element el, KLS_Region_List l) |
KLS_Region_List | kls_rl_insord (Koliseo *kls, KLS_list_element el, KLS_Region_List l) |
KLS_Region_List | kls_rl_insord_p (Koliseo *kls, KLS_list_element el, KLS_Region_List l) |
KLS_Region_List | kls_rl_mergeList (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2) |
KLS_Region_List | kls_rl_intersect (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2) |
KLS_Region_List | kls_rl_diff (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2) |
bool | kls_rl_isLess (KLS_Region *r1, KLS_Region *r2) |
Compares two regions and returns true if the first one has a smaller size. | |
bool | kls_rl_isEqual (KLS_Region *r1, KLS_Region *r2) |
Compares two regions and returns true if their size is equal. | |
double | kls_usageShare (KLS_Region *r, Koliseo *kls) |
Returns the ratio of memory used by the passed KLS_Region relative to the passed Koliseo as a double. | |
ptrdiff_t | kls_regionSize (KLS_Region *r) |
Return size of a passed KLS_Region. | |
ptrdiff_t | kls_avg_regionSize (Koliseo *kls) |
Return average region size in usage for the passed Koliseo. | |
void | kls_usageReport_toFile (Koliseo *kls, FILE *fp) |
Prints an usage report for the passed Koliseo to the passed file. | |
void | kls_usageReport (Koliseo *kls) |
Print usage report for passed Koliseo to stdout. | |
ptrdiff_t | kls_type_usage (int type, Koliseo *kls) |
Calc memory used by the specific type of KLS_list_element. | |
const char * | string_from_Gulp_Res (Gulp_Res g) |
Return a constant string for the passed Gulp_Res. | |
Kstr | kstr_new (const char *data, size_t len) |
Returns a new Kstr with the passed args set. | |
Kstr | kstr_from_c_lit (const char *c_lit) |
Returns a new Kstr from the passed null-terminated string. | |
bool | kstr_eq (Kstr left, Kstr right) |
Checks if the two passed Kstr have exactly equal data. | |
bool | kstr_eq_ignorecase (Kstr left, Kstr right) |
Checks if the two passed Kstr have equal data, ignoring case. | |
Kstr | kstr_cut_l (Kstr *k, size_t n) |
Cuts the passed Kstr by up to n chars, from the left. | |
Kstr | kstr_cut_r (Kstr *k, size_t n) |
Cuts the passed Kstr by up to n chars, from the right. | |
Kstr | kstr_trim_left (Kstr kstr) |
Returns a new Kstr after removing heading spaces from the passed one. | |
Kstr | kstr_trim_right (Kstr kstr) |
Returns a new Kstr after removing trailing spaces from the passed one. | |
Kstr | kstr_trim (Kstr kstr) |
Returns a new Kstr after removing heading and trailing spaces from the passed one. | |
bool | kstr_indexof (Kstr k, char c, int *idx) |
Checks if passed Kstr contains the passed char, and if so, sets the value pointed by idx to the first occurrence. | |
bool | kstr_try_token (Kstr *k, char delim, Kstr *part) |
Scans the first passed Kstr and if the passed char is present, the old Kstr is set to second pointer and the first one is cut at the first occurrence of it. | |
Kstr | kstr_token (Kstr *k, char delim) |
Scans the passed Kstr and cuts it up to the first occurrence of passed char, even if it is not present. | |
Kstr | kstr_token_kstr (Kstr *k, Kstr delim) |
char * | kls_gulp_file_sized (Koliseo *kls, const char *filepath, Gulp_Res *err, size_t max_size) |
Tries mapping the passed file on the Koliseo. | |
char * | try_kls_gulp_file (Koliseo *kls, const char *filepath, size_t max_size) |
Tries mapping the passed file on the Koliseo. | |
Kstr * | kls_gulp_file_sized_to_kstr (Koliseo *kls, const char *filepath, Gulp_Res *err, size_t max_size, bool allow_nullchar) |
Tries mapping the passed file on the Koliseo. | |
Kstr * | try_kls_gulp_file_to_kstr (Koliseo *kls, const char *filepath, size_t max_size, bool allow_nullchar) |
Tries mapping the passed file on the Koliseo. | |
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 |
const char * | kls_reglist_backend_strings [KLS_REGLIST_TOTAL_BACKENDS] |
const char * | gulp_res_names [TOT_GULP_RES+1] |
Contains the constant string representation of Gulp_Res values. | |
int int_koliseo_version | ( | void | ) |
Returns the constant int representing current version for Koliseo.
ptrdiff_t kls_avg_regionSize | ( | Koliseo * | kls | ) |
Return average region size in usage for the passed Koliseo.
kls | The Koliseo to check usage for. |
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, | ||
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, | ||
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. |
int kls_get_maxRegions_KLS_BASIC | ( | Koliseo * | kls | ) |
Calcs the max number of possible KLS_PUSH ops when using KLS_BASIC reglist alloc backend.
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. |
char * kls_gulp_file_sized | ( | Koliseo * | kls, |
const char * | filepath, | ||
Gulp_Res * | err, | ||
size_t | max_size ) |
Tries mapping the passed file on the Koliseo.
Sets the passed Gulp_Res to the result of the operation, .
kls | The Koliseo to push to. |
filepath | Path to the file to gulp. |
err | Pointer to the Gulp_Res variable to store result. |
max_size | Max size allowed for the read file. |
Kstr * kls_gulp_file_sized_to_kstr | ( | Koliseo * | kls, |
const char * | filepath, | ||
Gulp_Res * | err, | ||
size_t | max_size, | ||
bool | allow_nullchar ) |
Tries mapping the passed file on the Koliseo.
Sets the passed Gulp_Res to the result of the operation.
kls | The Koliseo to push to. |
filepath | Path to the file to gulp. |
err | Pointer to the Gulp_Res variable to store result. |
max_size | Max size allowed for the read file. |
allow_nullchar | Bool to avoid returning NULL for a binary file. |
KLS_region_list_item * kls_list_pop | ( | Koliseo * | kls | ) |
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_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.
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. |
Koliseo * kls_new_traced_AR_KLS_alloc | ( | ptrdiff_t | size, |
const char * | output_path, | ||
ptrdiff_t | reglist_kls_size, | ||
kls_alloc_func | alloc_func ) |
Takes a ptrdiff_t size and a filepath for the trace output file, and the needed parameters for a successful init of 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. |
reglist_kls_size | The size to use for the inner reglist Koliseo. |
alloc_func | The allocation function to use. |
Koliseo * kls_new_traced_AR_KLS_alloc_handled | ( | ptrdiff_t | size, |
const char * | output_path, | ||
ptrdiff_t | reglist_kls_size, | ||
kls_alloc_func | alloc_func, | ||
KLS_Err_Handlers | err_handlers ) |
Takes a ptrdiff_t size and a filepath for the trace output file, and the needed parameters for a successful init of 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. |
reglist_kls_size | The size to use for the inner reglist Koliseo. |
alloc_func | The allocation function to use. |
err_handlers | The error handlers 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_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 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_named | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count, | ||
char * | name, | ||
char * | desc ) |
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. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. 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. |
name | The name to assign to the resulting KLS_Region. |
desc | The desc to assign to the resulting KLS_Region. |
void * kls_push_zero_typed | ( | Koliseo * | kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count, | ||
int | type, | ||
char * | name, | ||
char * | desc ) |
Takes a Koliseo pointer, a KLS_Region_Type index, 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. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. 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. |
type | The type index for pushed KLS_Region. |
name | The name to assign to the resulting KLS_Region. |
desc | The desc to assign to the resulting KLS_Region. |
ptrdiff_t kls_regionSize | ( | KLS_Region * | r | ) |
Return size of a passed KLS_Region.
Sugar.
r | The KLS_Region. |
const char * kls_reglist_backend_string | ( | KLS_RegList_Alloc_Backend | kls_be | ) |
KLS_Region_List kls_rl_append | ( | Koliseo * | kls, |
KLS_Region_List | l1, | ||
KLS_Region_List | l2 ) |
KLS_Region_List kls_rl_cons | ( | Koliseo * | kls, |
KLS_list_element | e, | ||
KLS_Region_List | l ) |
KLS_Region_List kls_rl_copy | ( | Koliseo * | kls, |
KLS_Region_List | l ) |
KLS_Region_List kls_rl_delete | ( | Koliseo * | kls, |
KLS_list_element | el, | ||
KLS_Region_List | l ) |
KLS_Region_List kls_rl_diff | ( | Koliseo * | kls, |
KLS_Region_List | l1, | ||
KLS_Region_List | l2 ) |
bool kls_rl_empty | ( | KLS_Region_List | l | ) |
KLS_Region_List kls_rl_emptyList | ( | void | ) |
void kls_rl_freeList | ( | KLS_Region_List | l | ) |
Frees all values and nodes for passed Region list.
Should only be used internally for operations with ALLOC_LIBC for allocation backend.
l | The list to free (allocated by using malloc). |
KLS_list_element kls_rl_head | ( | KLS_Region_List | l | ) |
KLS_Region_List kls_rl_insord | ( | Koliseo * | kls, |
KLS_list_element | el, | ||
KLS_Region_List | l ) |
KLS_Region_List kls_rl_insord_p | ( | Koliseo * | kls, |
KLS_list_element | el, | ||
KLS_Region_List | l ) |
KLS_Region_List kls_rl_intersect | ( | Koliseo * | kls, |
KLS_Region_List | l1, | ||
KLS_Region_List | l2 ) |
bool kls_rl_isEqual | ( | KLS_Region * | r1, |
KLS_Region * | r2 ) |
Compares two regions and returns true if their size is equal.
r1 | The first KLS_Region |
r2 | The second KLS_Region |
bool kls_rl_isLess | ( | KLS_Region * | r1, |
KLS_Region * | r2 ) |
Compares two regions and returns true if the first one has a smaller size.
r1 | The KLS_Region expected to be smaller |
r2 | The KLS_Region expected to be bigger |
int kls_rl_length | ( | KLS_Region_List | l | ) |
bool kls_rl_member | ( | KLS_list_element | el, |
KLS_Region_List | l ) |
KLS_Region_List kls_rl_mergeList | ( | Koliseo * | kls, |
KLS_Region_List | l1, | ||
KLS_Region_List | l2 ) |
KLS_Region_List kls_rl_reverse | ( | Koliseo * | kls, |
KLS_Region_List | l ) |
void kls_rl_showList | ( | KLS_Region_List | l | ) |
void kls_rl_showList_toFile | ( | KLS_Region_List | l, |
FILE * | fp ) |
KLS_Region_List kls_rl_t_cons | ( | Koliseo_Temp * | t_kls, |
KLS_list_element | e, | ||
KLS_Region_List | l ) |
KLS_Region_List kls_rl_tail | ( | KLS_Region_List | l | ) |
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.
KLS_region_list_item * kls_t_list_pop | ( | Koliseo_Temp * | t_kls | ) |
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. |
int kls_temp_get_maxRegions_KLS_BASIC | ( | Koliseo_Temp * | t_kls | ) |
Calcs the max number of possible KLS_PUSH_T ops when using KLS_BASIC reglist alloc backend.
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_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 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.
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. |
void * kls_temp_push_zero_named | ( | Koliseo_Temp * | t_kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count, | ||
char * | name, | ||
char * | desc ) |
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. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. Notably, it zeroes the memory region.
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. |
name | The name to assign to the resulting KLS_Region. |
desc | The desc to assign to the resulting KLS_Region. |
void * kls_temp_push_zero_typed | ( | Koliseo_Temp * | t_kls, |
ptrdiff_t | size, | ||
ptrdiff_t | align, | ||
ptrdiff_t | count, | ||
int | type, | ||
char * | name, | ||
char * | desc ) |
Takes a Koliseo_Temp, a KLS_Region_Type index, 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. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. Notably, it zeroes the memory region.
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. |
type | The type index for pushed KLS_Region. |
name | The name to assign to the resulting KLS_Region. |
desc | The desc to assign to the resulting KLS_Region. |
bool kls_temp_set_conf | ( | Koliseo_Temp * | t_kls, |
KLS_Temp_Conf | conf ) |
Updates the KLS_Temp_Conf for the passed Koliseo_Temp pointer.
t_kls | The Koliseo_Temp pointer to update. |
conf | The KLS_Temp_Conf to set. |
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. |
ptrdiff_t kls_type_usage | ( | int | type, |
Koliseo * | kls ) |
Calc memory used by the specific type of KLS_list_element.
type | The integer corresponding to element->type |
kls | The Koliseo to check usage for. |
void kls_usageReport | ( | Koliseo * | kls | ) |
Print usage report for passed Koliseo to stdout.
kls | The Koliseo to print info for. |
void kls_usageReport_toFile | ( | Koliseo * | kls, |
FILE * | fp ) |
Prints an usage report for the passed Koliseo to the passed file.
kls | The Koliseo to check. |
fp | The file pointer to print to. |
double kls_usageShare | ( | KLS_Region * | r, |
Koliseo * | kls ) |
Returns the ratio of memory used by the passed KLS_Region relative to the passed Koliseo as a double.
r | The KLS_Region to check relative size for. |
kls | The Koliseo to check on. |
Kstr kstr_cut_l | ( | Kstr * | k, |
size_t | n ) |
Cuts the passed Kstr by up to n chars, from the left.
Returns cut portion as a new Kstr.
k | The Kstr to cut. |
n | How many chars to cut. |
Kstr kstr_cut_r | ( | Kstr * | k, |
size_t | n ) |
Cuts the passed Kstr by up to n chars, from the right.
Returns cut portion as a new Kstr.
k | The Kstr to cut. |
n | How many chars to cut. |
bool kstr_eq | ( | Kstr | left, |
Kstr | right ) |
Checks if the two passed Kstr have exactly equal data.
left | The first Kstr to compare. |
right | The second Kstr to compare. |
bool kstr_eq_ignorecase | ( | Kstr | left, |
Kstr | right ) |
Checks if the two passed Kstr have equal data, ignoring case.
left | The first Kstr to compare. |
right | The second Kstr to compare. |
Kstr kstr_from_c_lit | ( | const char * | c_lit | ) |
Returns a new Kstr from the passed null-terminated string.
c_lit | The cstring pointer to set. |
bool kstr_indexof | ( | Kstr | k, |
char | c, | ||
int * | idx ) |
Checks if passed Kstr contains the passed char, and if so, sets the value pointed by idx to the first occurrence.
k | The Kstr to scan. |
c | The char to look for. |
idx | Pointer to the value to be set as index. |
Kstr kstr_new | ( | const char * | data, |
size_t | len ) |
Returns a new Kstr with the passed args set.
data | The string pointer to set. |
len | The len to set. |
Kstr kstr_token | ( | Kstr * | k, |
char | delim ) |
Scans the passed Kstr and cuts it up to the first occurrence of passed char, even if it is not present.
Returns a new Kstr with the original data.
k | The Kstr to scan. |
delim | The char to look for. |
Kstr kstr_token_kstr | ( | Kstr * | k, |
Kstr | delim ) |
Kstr kstr_trim | ( | Kstr | kstr | ) |
Returns a new Kstr after removing heading and trailing spaces from the passed one.
kstr | The Kstr to trim. |
Kstr kstr_trim_left | ( | Kstr | kstr | ) |
Returns a new Kstr after removing heading spaces from the passed one.
kstr | The Kstr to trim. |
Kstr kstr_trim_right | ( | Kstr | kstr | ) |
Returns a new Kstr after removing trailing spaces from the passed one.
kstr | The Kstr to trim. |
bool kstr_try_token | ( | Kstr * | k, |
char | delim, | ||
Kstr * | part ) |
Scans the first passed Kstr and if the passed char is present, the old Kstr is set to second pointer and the first one is cut at the first occurrence of it.
k | The Kstr to scan. |
delim | The char to look for. |
part | The Kstr to set to the original data, if the delimiter is found. |
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_from_Gulp_Res | ( | Gulp_Res | g | ) |
Return a constant string for the passed Gulp_Res.
g | The Gulp_Res to get a string for. |
const char * string_koliseo_version | ( | void | ) |
Returns the constant string representing current version for Koliseo.
char * try_kls_gulp_file | ( | Koliseo * | kls, |
const char * | filepath, | ||
size_t | max_size ) |
Tries mapping the passed file on the Koliseo.
kls | The Koliseo to push to. |
filepath | Path to the file to gulp. |
max_size | Max size allowed for the read file. |
Kstr * try_kls_gulp_file_to_kstr | ( | Koliseo * | kls, |
const char * | filepath, | ||
size_t | max_size, | ||
bool | allow_nullchar ) |
Tries mapping the passed file on the Koliseo.
kls | The Koliseo to push to. |
filepath | Path to the file to gulp. |
max_size | Max size allowed for the read file. |
allow_nullchar | Boolean to avoid returning NULL for a binary file. |
const char* gulp_res_names[TOT_GULP_RES+1] |
Contains the constant string representation of Gulp_Res values.
KLS_Conf KLS_DEFAULT_CONF |
Config used by any new Koliseo by default.
const char* kls_reglist_backend_strings[KLS_REGLIST_TOTAL_BACKENDS] |
KLS_Stats KLS_STATS_DEFAULT |