koliseo 0.6.4
Loading...
Searching...
No Matches
koliseo.h
Go to the documentation of this file.
1// jgabaut @ github.com/jgabaut
2// SPDX-License-Identifier: GPL-3.0-only
3/*
4 Copyright (C) 2023-2026 jgabaut
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, version 3 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19#ifndef KOLISEO_H_
20
21#if defined(__cplusplus)
22#define KLS_ALIGNOF alignof
23#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) //We need C11
24#define KLS_ALIGNOF _Alignof
25#elif defined(__GNUC__) || defined(__clang__)
26#define KLS_ALIGNOF __alignof__
27#else
28#define KLS_ALIGNOF(type) offsetof(struct { char c; type t; }, t)
29#endif // __STDC_VERSION__ && __STDC_VERSION__ >= 201112L //We need C11
30
31#define KOLISEO_H_
32
33#if defined(__cplusplus)
34extern "C" {
35#endif // __cplusplus
36
37#include <stdio.h>
38#include <stdint.h>
39#include <stddef.h>
40#include <stdlib.h>
41#include <stdarg.h>
42#include <assert.h>
43#include <string.h>
44#include <time.h>
45#include <stdbool.h>
46
47#ifdef KLS_DEBUG_CORE
48#include <time.h>
49
50/*
51#ifndef KOLISEO_HAS_LOCATE
52#define KOLISEO_HAS_LOCATE // Used for enabling caller location arguments for some APIs.
53#endif // KOLISEO_HAS_LOCATE
54*/
55
56#ifdef _WIN32
57#include <profileapi.h> //Used for QueryPerformanceFrequency(), QueryPerformanceCounter()
58#endif
59#endif //KLS_DEBUG_CORE
60
61#ifdef KOLISEO_HAS_LOCATE
62typedef struct Koliseo_Loc {
63 const char* file;
64 const int line;
65 const char* func;
66} Koliseo_Loc;
67
68#define KLS_HERE (Koliseo_Loc){ \
69 .file = __FILE__, \
70 .line = __LINE__, \
71 .func = __func__, \
72}
73
78#define KLS_Loc_Fmt "[%s:%i at %s():] "
79
84#define KLS_Loc_Arg(loc) (loc.file), (loc.line), (loc.func)
85#endif // KOLISEO_HAS_LOCATE
86
87#define KLS_MAJOR 0
88#define KLS_MINOR 6
89#define KLS_PATCH 4
90
91typedef void*(kls_alloc_func)(size_t);
92typedef void(kls_free_func)(void*);
93
94#define STRINGIFY_2(x) #x
95
96#define STRINGIFY(x) STRINGIFY_2(x)
97
98#define KLS_MAX(a, b) ((a) > (b) ? (a) : (b))
99
103static const int KOLISEO_API_VERSION_INT =
104 (KLS_MAJOR * 1000000 + KLS_MINOR * 10000 + KLS_PATCH * 100);
106
110static const char KOLISEO_API_VERSION_STRING[] = "0.6.4";
111
115const char *string_koliseo_version(void);
116
120int int_koliseo_version(void);
121
122#define KLS_DEFAULT_SIZE (16*1024)
123
124#ifndef KLS_DEFAULT_ALIGNMENT
125#define KLS_DEFAULT_ALIGNMENT (2*sizeof(void *))
126#endif
127
128struct Koliseo_Temp; //Forward declaration for Koliseo itself
129struct Koliseo; //Forward declaration for KLS_OOM_Handler
130
131#ifndef KOLISEO_HAS_LOCATE
132typedef void(KLS_OOM_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count);
133#else
134typedef void(KLS_OOM_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
135#endif
136
137#ifndef KOLISEO_HAS_LOCATE
138typedef void(KLS_PTRDIFF_MAX_Handler)(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count);
139#else
140typedef void(KLS_PTRDIFF_MAX_Handler)(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
141#endif
142
143#ifndef KOLISEO_HAS_LOCATE
144typedef void(KLS_ZEROCOUNT_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size);
145#else
146typedef void(KLS_ZEROCOUNT_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, Koliseo_Loc loc);
147#endif
148
149#ifndef KOLISEO_HAS_LOCATE
150void KLS_OOM_default_handler__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count);
151#else
152void KLS_OOM_default_handler_dbg__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
153#endif
154
155#ifndef KOLISEO_HAS_LOCATE
156void KLS_PTRDIFF_MAX_default_handler__(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count);
157#else
158void KLS_PTRDIFF_MAX_default_handler_dbg__(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
159#endif
160
161#ifndef KOLISEO_HAS_LOCATE
162void KLS_ZEROCOUNT_default_handler__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size);
163#else
164void KLS_ZEROCOUNT_default_handler_dbg__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, Koliseo_Loc loc);
165#endif
166
176
177#ifndef KOLISEO_HAS_LOCATE
178#define KLS_DEFAULT_ERR_HANDLERS (KLS_Err_Handlers) { .OOM_handler = &KLS_OOM_default_handler__, .PTRDIFF_MAX_handler = &KLS_PTRDIFF_MAX_default_handler__, .ZEROCOUNT_handler = &KLS_ZEROCOUNT_default_handler__, }
179#else
180#define KLS_DEFAULT_ERR_HANDLERS (KLS_Err_Handlers) { .OOM_handler = &KLS_OOM_default_handler_dbg__, .PTRDIFF_MAX_handler = &KLS_PTRDIFF_MAX_default_handler_dbg__, .ZEROCOUNT_handler = &KLS_ZEROCOUNT_default_handler_dbg__, }
181#endif // KOLISEO_HAS_LOCATE
182
183typedef void(KLS_hook_on_new)(struct Koliseo* kls);
184
185typedef void(KLS_hook_on_free)(struct Koliseo* kls);
186
187typedef void(KLS_hook_on_push)(struct Koliseo* kls, ptrdiff_t padding, const char* caller, void* user);
188
189typedef void(KLS_hook_on_repush_last)(struct Koliseo* kls, ptrdiff_t padding, const char* caller, void* user);
190
191typedef void(KLS_hook_on_temp_start)(struct Koliseo_Temp* t_kls);
192
193typedef void(KLS_hook_on_temp_free)(struct Koliseo_Temp* t_kls);
194
195typedef void(KLS_hook_on_temp_push)(struct Koliseo_Temp* t_kls, ptrdiff_t padding, const char* caller, void* user);
196
197typedef void(KLS_hook_on_temp_repush_last)(struct Koliseo_Temp* t_kls, ptrdiff_t padding, const char* caller, void* user);
198
209
216#ifndef KLS_DEFAULT_HOOKS
217#define KLS_DEFAULT_HOOKS (KLS_Hooks){0}
218#endif // KLS_DEFAULT_HOOKS
219
225#ifndef KLS_DEFAULT_EXTENSION_DATA
226#define KLS_DEFAULT_EXTENSION_DATA NULL
227#endif // KLS_DEFAULT_EXTENSION_DATA
228
243
244KLS_Conf kls_conf_init_handled(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, FILE* log_fp, const char* log_filepath, KLS_Err_Handlers err_handlers);
245
246KLS_Conf kls_conf_init(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, FILE* log_fp, const char* log_filepath);
247
248void kls_dbg_features(void);
249
254typedef struct KLS_Stats {
260#ifdef KLS_DEBUG_CORE
265#endif
267
274
281
286#define KLS_Conf_Fmt "KLS_Conf { collect_stats: %i, verbose_lvl: %i, log_filepath: \"%s\", log_fp: %p, block_while_has_temp: %i, allow_zerocount_push: %i }"
287
292#define KLS_Conf_Arg(conf) (conf.collect_stats),(conf.verbose_lvl),(conf.log_filepath),(void*)(conf.log_fp),(conf.block_while_has_temp),(conf.allow_zerocount_push)
293
298#ifdef KLS_DEBUG_CORE
299#define KLS_Stats_Fmt "KLS_Stats { tot_pushes: %i, tot_pops: %i, tot_temp_pushes: %i, tot_temp_pops: %i, worst_push_time: %.7f }"
300#else
301#define KLS_Stats_Fmt "KLS_Stats { tot_pushes: %i, tot_pops: %i, tot_temp_pushes: %i, tot_temp_pops: %i }"
302#endif // KLS_DEBUG_CORE
303
308#ifdef KLS_DEBUG_CORE
309#define KLS_Stats_Arg(stats) (stats.tot_pushes),(stats.tot_pops),(stats.tot_temp_pushes),(stats.tot_temp_pops),(stats.worst_pushcall_time)
310#else
311#define KLS_Stats_Arg(stats) (stats.tot_pushes),(stats.tot_pops),(stats.tot_temp_pushes),(stats.tot_temp_pops)
312#endif // KLS_DEBUG_CORE
313
337
342#ifndef _WIN32
343#define KLSFmt "KLS {begin: %p, curr: %p, size: %li, offset: %li, has_temp: %i}"
344#else
345#define KLSFmt "KLS {begin: %p, curr: %p, size: %lli, offset: %lli, has_temp: %i}"
346#endif
347
352#define KLS_Arg(kls) (void*)(kls),(void*)((kls)+(kls->offset)),(kls->size),(kls->offset),(kls->has_temp)
353
361typedef struct Koliseo_Temp {
363 ptrdiff_t offset;
364 ptrdiff_t prev_offset;
366
383
393
394void kls_log(Koliseo * kls, const char *tag, const char *format, ...);
395ptrdiff_t kls_get_pos(const Koliseo * kls);
396
397#ifndef KOLISEO_HAS_LOCATE
398Koliseo *kls_new_alloc_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks ext_handlers, void* user);
399#else
400Koliseo *kls_new_alloc_ext_dbg(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks ext_handlers, void* user, Koliseo_Loc loc);
401#define kls_new_alloc_ext(size, alloc_func, free_func, ext_handlers, user) kls_new_alloc_ext_dbg((size), (alloc_func), (free_func), (ext_handlers), (user), KLS_HERE)
402#endif // KOLISEO_HAS_LOCATE
403
404#ifndef KOLISEO_HAS_LOCATE
405Koliseo *kls_new_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func);
406#else
407Koliseo *kls_new_alloc_dbg(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, Koliseo_Loc loc);
408#define kls_new_alloc(size, alloc_func, free_func) kls_new_alloc_dbg((size), (alloc_func), (free_func), KLS_HERE)
409#endif // KOLISEO_HAS_LOCATE
410
411#if defined(KLS_DEFAULT_ALLOCF) != defined(KLS_DEFAULT_FREEF)
412#error "KLS_DEFAULT_ALLOCF and KLS_DEFAULT_FREEF must either both be defined or both be left undefined."
413#endif
414
415#ifndef KLS_DEFAULT_ALLOCF
416#define KLS_DEFAULT_ALLOCF malloc
417#endif
418
419#ifndef KLS_DEFAULT_FREEF
420#define KLS_DEFAULT_FREEF free
421#endif
422
423Koliseo* kls_new(ptrdiff_t size);
424//bool kls_set_conf(Koliseo* kls, KLS_Conf conf);
425Koliseo *kls_new_conf_alloc_ext(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks ext_handlers, void* user);
427Koliseo *kls_new_conf_ext(ptrdiff_t size, KLS_Conf conf, KLS_Hooks ext_handlers, void* user);
428Koliseo *kls_new_conf(ptrdiff_t size, KLS_Conf conf);
429
430Koliseo *kls_new_traced_alloc_handled_ext(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks ext_handlers, void* user);
431Koliseo *kls_new_traced_alloc_handled(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers);
432Koliseo *kls_new_traced_ext(ptrdiff_t size, const char *output_path, KLS_Hooks ext_handlers, void* user);
433Koliseo *kls_new_traced_alloc(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func);
434Koliseo *kls_new_traced(ptrdiff_t size, const char* output_path);
435Koliseo *kls_new_traced_handled(ptrdiff_t size, const char* output_path, KLS_Err_Handlers err_handlers);
436
437Koliseo *kls_new_dbg_alloc_handled_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks ext_handlers, void* user);
438Koliseo *kls_new_dbg_alloc_handled(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers);
439Koliseo *kls_new_dbg_ext(ptrdiff_t size, KLS_Hooks ext_handlers, void* user);
440Koliseo *kls_new_dbg_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func);
441Koliseo *kls_new_dbg(ptrdiff_t size);
442Koliseo *kls_new_dbg_handled(ptrdiff_t size, KLS_Err_Handlers err_handlers);
443
444#ifndef KOLISEO_HAS_LOCATE
445void* kls__handle_push_result(Koliseo* kls, KLS_Push_Result r, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t padding, const char* caller_name);
446#else
447void* kls__handle_push_result_dbg(Koliseo* kls, KLS_Push_Result r, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t padding, const char* caller_name, Koliseo_Loc loc);
448#endif // KOLISEO_HAS_LOCATE
449
450#ifndef KOLISEO_HAS_LOCATE
451KLS_Push_Result kls__advance(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name);
452#else
453KLS_Push_Result kls__advance_dbg(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name, Koliseo_Loc loc);
454#endif // KOLISEO_HAS_LOCATE
455
456#ifndef KOLISEO_HAS_LOCATE
457KLS_Push_Result kls__temp_advance(Koliseo_Temp* t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name);
458#else
459KLS_Push_Result kls__temp_advance_dbg(Koliseo_Temp* t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name, Koliseo_Loc loc);
460#endif // KOLISEO_HAS_LOCATE
461
462#ifndef KOLISEO_HAS_LOCATE
463KLS_Push_Error kls__check_available(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, const char* caller_name);
464#else
465KLS_Push_Error kls__check_available_dbg(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, const char* caller_name, Koliseo_Loc loc);
466#endif // KOLISEO_HAS_LOCATE
467
468//void* kls_push(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
469
470#ifndef KOLISEO_HAS_LOCATE
471void *kls_push_zero(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
472 ptrdiff_t count);
473#else
474void *kls_push_zero_dbg(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
475 ptrdiff_t count, Koliseo_Loc loc);
476
477#define kls_push_zero(kls, size, align, count) kls_push_zero_dbg((kls), (size), (align), (count), KLS_HERE)
478#endif // KOLISEO_HAS_LOCATE
479
480#ifndef KOLISEO_HAS_LOCATE
481void *kls_push_zero_ext(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
482 ptrdiff_t count);
483#else
484void *kls_push_zero_ext_dbg(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
485 ptrdiff_t count, Koliseo_Loc loc);
486#define kls_push_zero_ext(kls, size, align, count) kls_push_zero_ext_dbg((kls), (size), (align), (count), KLS_HERE)
487#endif // KOLISEO_HAS_LOCATE
488
489#ifndef KOLISEO_HAS_LOCATE
490char* kls_vsprintf(Koliseo* kls, const char* fmt, va_list args);
491#else
492char* kls_vsprintf_dbg(Koliseo* kls, Koliseo_Loc loc, const char* fmt, va_list args);
493#define kls_vsprintf(kls, fmt, args) kls_vsprintf_dbg((kls), KLS_HERE, (fmt), (args))
494#endif // KOLISEO_HAS_LOCATE
495
496#ifndef KOLISEO_HAS_LOCATE
497char* kls_sprintf(Koliseo* kls, const char* fmt, ...);
498#else
499char* kls_sprintf_dbg(Koliseo* kls, Koliseo_Loc loc, const char* fmt, ...);
500#define kls_sprintf(kls, fmt, ...) kls_sprintf_dbg((kls), KLS_HERE, (fmt), __VA_ARGS__)
501#endif // KOLISEO_HAS_LOCATE
502
503bool kls_contains_pointer(const Koliseo *kls, const void *ptr);
504
505#ifndef KOLISEO_HAS_LOCATE
506void *kls_repush(Koliseo *kls, void* old, ptrdiff_t size, ptrdiff_t align,
507 ptrdiff_t old_count, ptrdiff_t new_count);
508#else
509void *kls_repush_dbg(Koliseo *kls, void* old, ptrdiff_t size, ptrdiff_t align,
510 ptrdiff_t old_count, ptrdiff_t new_count, Koliseo_Loc loc);
511#define kls_repush(kls, old, size, align, old_count, new_count) kls_repush_dbg((kls), (old), (size), (align), (old_count), (new_count), KLS_HERE)
512#endif // KOLISEO_HAS_LOCATE
513
514#ifndef KOLISEO_HAS_LOCATE
515void *kls_temp_repush(Koliseo_Temp *t_kls, void* old, ptrdiff_t size, ptrdiff_t align,
516 ptrdiff_t old_count, ptrdiff_t new_count);
517#else
518void *kls_temp_repush_dbg(Koliseo_Temp *t_kls, void* old, ptrdiff_t size, ptrdiff_t align,
519 ptrdiff_t old_count, ptrdiff_t new_count, Koliseo_Loc loc);
520#define kls_temp_repush(t_kls, old, size, align, old_count, new_count) kls_temp_repush_dbg((t_kls), (old), (size), (align), (old_count), (new_count), KLS_HERE)
521#endif // KOLISEO_HAS_LOCATE
522
526#define KLS_PUSH_ARR(kls, type, count) (type*)kls_push_zero_ext((kls), sizeof(type), KLS_ALIGNOF(type), (count))
527
531#define KLS_SPRINTF(kls, fmt, ...) kls_sprintf((kls), (fmt), __VA_ARGS__)
532
538#define KLS_PUSH_STR(kls, cstr) KLS_PUSH_ARR((kls), char, strlen((cstr))+1)
539
543#define KLS_REPUSH(kls, old, type, old_count, new_count) (type*)kls_repush((kls), (old), sizeof(type), KLS_ALIGNOF(type), (old_count), (new_count))
544
548#define KLS_REPUSH_T(t_kls, old, type, old_count, new_count) (type*)kls_temp_repush((t_kls), (old), sizeof(type), KLS_ALIGNOF(type), (old_count), (new_count))
549
553#define KLS_PUSH_ARR_NAMED(kls, type, count, name, desc) KLS_PUSH_ARR((kls),type,(count))
554
559#define KLS_PUSH_STR_NAMED(kls, cstr, name, desc) KLS_PUSH_ARR_NAMED((kls), char, strlen((cstr))+1, (name), (desc))
560
564#define KLS_PUSH_ARR_TYPED(kls, type, count, region_type, name, desc) KLS_PUSH_ARR((kls),type,(count))
565
570#define KLS_PUSH_STR_TYPED(kls, cstr, region_type, name, desc) KLS_PUSH_ARR_TYPED((kls), char, strlen((cstr))+1, (region_type), (name), (desc))
571
575#define KLS_PUSH(kls, type) KLS_PUSH_ARR((kls), type, 1)
576
580#define KLS_PUSH_NAMED(kls, type, name, desc) KLS_PUSH_ARR_NAMED((kls), type, 1, (name), (desc))
581
586#define KLS_PUSH_EX(kls, type, name) KLS_PUSH_NAMED((kls), type, (name), STRINGIFY(type))
587
591#define KLS_PUSH_TYPED(kls, type, region_type, name, desc) KLS_PUSH_ARR_TYPED((kls), type, 1, (region_type), (name), (desc))
592
597#define KLS_PUSH_TYPED_EX(kls, type, region_type, name) KLS_PUSH_TYPED((kls), type, (region_type), (name), STRINGIFY(type))
598
599void kls_clear(Koliseo * kls);
600void kls_free(Koliseo * kls);
601void print_kls_2file(FILE * fp, const Koliseo * kls);
602void print_dbg_kls(const Koliseo * kls);
603void kls_formatSize(size_t size, char *outputBuffer, size_t bufferSize);
604
605#ifndef KOLISEO_HAS_LOCATE
607#else
608Koliseo_Temp *kls_temp_start_dbg(Koliseo * kls, Koliseo_Loc loc);
609#define kls_temp_start(kls) kls_temp_start_dbg((kls), KLS_HERE)
610#endif // KOLISEO_HAS_LOCATE
611//bool kls_temp_set_conf(Koliseo_Temp* t_kls, KLS_Temp_Conf conf);
612void kls_temp_end(Koliseo_Temp * tmp_kls);
613
614#ifndef KOLISEO_HAS_LOCATE
615void *kls_temp_push_zero_ext(Koliseo_Temp * t_kls, ptrdiff_t size,
616 ptrdiff_t align, ptrdiff_t count);
617#else
618void *kls_temp_push_zero_ext_dbg(Koliseo_Temp * t_kls, ptrdiff_t size,
619 ptrdiff_t align, ptrdiff_t count, Koliseo_Loc loc);
620#define kls_temp_push_zero_ext(t_kls, size, align, count) kls_temp_push_zero_ext_dbg((t_kls), (size), (align), (count), KLS_HERE)
621#endif // KOLISEO_HAS_LOCATE
622
623#ifndef KOLISEO_HAS_LOCATE
624char* kls_temp_vsprintf(Koliseo_Temp* kls_t, const char* fmt, va_list args);
625#else
626char* kls_temp_vsprintf_dbg(Koliseo_Temp* kls_t, Koliseo_Loc loc, const char* fmt, va_list args);
627#define kls_temp_vsprintf(t_kls, fmt, args) kls_temp_vsprintf_dbg((t_kls), KLS_HERE, (fmt), (args))
628#endif // KOLISEO_HAS_LOCATE
629
630#ifndef KOLISEO_HAS_LOCATE
631char* kls_temp_sprintf(Koliseo_Temp* kls_t, const char* fmt, ...);
632#else
633char* kls_temp_sprintf_dbg(Koliseo_Temp* kls_t, Koliseo_Loc loc, const char* fmt, ...);
634#define kls_temp_sprintf(t_kls, fmt, ...) kls_temp_sprintf_dbg((t_kls), KLS_HERE, (fmt), __VA_ARGS__)
635#endif // KOLISEO_HAS_LOCATE
636
637void print_temp_kls_2file(FILE * fp, const Koliseo_Temp * t_kls);
638void print_dbg_temp_kls(const Koliseo_Temp * t_kls);
639
643#define KLS_PUSH_ARR_T(kls_temp, type, count) (type*)kls_temp_push_zero_ext((kls_temp), sizeof(type), KLS_ALIGNOF(type), (count))
644
648#define KLS_SPRINTF_T(kls_temp, fmt, ...) kls_temp_sprintf((kls_temp), (fmt), __VA_ARGS__)
649
655#define KLS_PUSH_STR_T(kls_temp, cstr) KLS_PUSH_ARR_T((kls_temp), char, strlen((cstr))+1)
656
660#define KLS_PUSH_ARR_T_NAMED(kls_temp, type, count, name, desc) KLS_PUSH_ARR_T((kls_temp),type,(count))
661
666#define KLS_PUSH_STR_T_NAMED(kls_temp, cstr, name, desc) KLS_PUSH_ARR_T_NAMED((kls_temp), char, strlen((cstr))+1, (name), (desc))
667
671#define KLS_PUSH_ARR_T_TYPED(kls_temp, type, count, region_type, name, desc) KLS_PUSH_ARR_T((kls_temp),type,(count))
672
677#define KLS_PUSH_STR_T_TYPED(kls_temp, cstr, region_type, name, desc) KLS_PUSH_ARR_T_TYPED((kls_temp), char, strlen((cstr))+1, (region_type), (name), (desc))
678
682#define KLS_PUSH_T(kls_temp, type) KLS_PUSH_ARR_T((kls_temp), type, 1)
683
687#define KLS_PUSH_T_NAMED(kls_temp, type, name, desc) KLS_PUSH_ARR_T_NAMED((kls_temp), type, 1, (name), (desc))
688
693#define KLS_PUSH_T_EX(kls_temp, type, name) KLS_PUSH_T_NAMED((kls_temp), type, (name), STRINGIFY(type))
694
698#define KLS_PUSH_T_TYPED(kls_temp, type, region_type, name, desc) KLS_PUSH_ARR_T_TYPED((kls_temp), type, 1, (region_type), (name), (desc))
699
704#define KLS_PUSH_T_TYPED_EX(kls_temp, type, region_type, name) KLS_PUSH_T_TYPED((kls_temp), type, (region_type), (name), STRINFIGY(type))
705
706#ifdef KOLISEO_HAS_EXPER
707
708void *kls_pop(Koliseo * kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
709
714#define KLS_POP_ARR(kls, type, count) (type*)kls_pop((kls), sizeof(type), KLS_ALIGNOF(type), (count))
715
720#define KLS_POP_STR(kls, cstr) KLS_POP_ARR((kls), char, strlen((cstr)))
721
726#define KLS_POP(kls, type) KLS_POP_ARR((kls), type, 1)
727
728void *kls_temp_pop(Koliseo_Temp * t_kls, ptrdiff_t size, ptrdiff_t align,
729 ptrdiff_t count);
730
735#define KLS_POP_ARR_T(kls_temp, type, count) (type*)kls_temp_pop((kls_temp), sizeof(type), KLS_ALIGNOF(type), (count))
736
741#define KLS_POP_STR_T(kls_temp, cstr) KLS_POP_ARR_T((kls_temp), char, strlen((cstr)))
742
747#define KLS_POP_T(kls_temp, type) KLS_POP_ARR_T((kls_temp), type, 1)
748
749char* kls_strdup(Koliseo* kls, char* source);
750char** kls_strdup_arr(Koliseo* kls, size_t count, char** source);
751
759#define KLS__STRCPY(dest, source) do {\
760 strcpy((dest), (source));\
761} while (0)
762
763/*
764 * Macro to dupe a C string to a passed Koliseo, returns a pointer to the allocated string.
765 * Unsafe, do not use.
766 * @see kls_strdup()
767 */
768#define KLS_STRDUP(kls, source) kls_strdup((kls), (source))
769
770char* kls_t_strdup(Koliseo_Temp* t_kls, char* source);
771char** kls_t_strdup_arr(Koliseo_Temp* t_kls, size_t count, char** source);
772
773/*
774 * Macro to dupe a C string to a passed Koliseo_Temp, returns a pointer to the allocated string.
775 * Unsafe, do not use.
776 * @see kls_t_strdup()
777 */
778#define KLS_STRDUP_T(t_kls, source) kls_t_strdup((t_kls), (source))
779
780#endif // KOLISEO_HAS_EXPER
781
782#if defined(__cplusplus)
783}
784#endif // __cplusplus
785#endif //KOLISEO_H_
786
KLS_Stats KLS_STATS_DEFAULT
Default KLS_Stats values, used by kls_new().
Definition koliseo.c:46
KLS_Conf KLS_DEFAULT_CONF
Config used by any new Koliseo by default.
Definition koliseo.c:25
void kls_free_func(void *)
Used to select a free function for the arena's backing memory.
Definition koliseo.h:92
Koliseo * kls_new_traced(ptrdiff_t size, const char *output_path)
Takes a ptrdiff_t size and a filepath for the trace output file.
Definition koliseo.c:851
Koliseo * kls_new(ptrdiff_t size)
Takes a ptrdiff_t size.
Definition koliseo.c:659
char * kls_strdup(Koliseo *kls, char *source)
Function to dupe a C string to a Koliseo, and return a pointer to the allocated string.
Definition koliseo.c:2389
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.
Definition koliseo.c:2350
Koliseo_Temp * kls_temp_start(Koliseo *kls)
Starts a new savestate for the passed Koliseo pointer, by initialising its Koliseo_Temp pointer and r...
Definition koliseo.c:2209
void KLS_hook_on_new(struct Koliseo *kls)
Used to pass an extension handler for kls_new_alloc().
Definition koliseo.h:183
void print_dbg_temp_kls(const Koliseo_Temp *t_kls)
Prints header fields from the passed Koliseo_Temp pointer, to stderr.
Definition koliseo.c:2071
void KLS_OOM_default_handler__(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count)
Used by default when no handler is passed.
Definition koliseo.c:96
void * kls_temp_repush(Koliseo_Temp *t_kls, void *old, ptrdiff_t size, ptrdiff_t align, ptrdiff_t old_count, ptrdiff_t new_count)
Takes a Koliseo_Temp pointer, and a void pointer to the old allocation, ptrdiff_t values for size,...
Definition koliseo.c:1814
Koliseo * kls_new_dbg_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func)
Takes a ptrdiff_t size, an allocation function pointer and a free function pointer,...
Definition koliseo.c:952
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.
Definition koliseo.c:2032
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.
Definition koliseo.c:2418
Koliseo * kls_new_traced_alloc_handled(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size, a filepath for the trace output file, an allocation function pointer and a fr...
Definition koliseo.c:798
void kls_formatSize(size_t size, char *outputBuffer, size_t bufferSize)
Converts a ptrdiff_t size to human-readable SI units (modulo 1000).
Definition koliseo.c:2083
void KLS_OOM_Handler(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count)
Used to pass an error handler for Out-Of-Memory error.
Definition koliseo.h:132
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....
Definition koliseo.c:499
void KLS_hook_on_temp_start(struct Koliseo_Temp *t_kls)
Used to pass an extension handler for kls_temp_start().
Definition koliseo.h:191
char * kls_vsprintf(Koliseo *kls, const char *fmt, va_list args)
Definition koliseo.c:1472
void kls_temp_end(Koliseo_Temp *tmp_kls)
Ends passed Koliseo_Temp pointer.
Definition koliseo.c:2260
void kls_dbg_features(void)
Prints enabled Koliseo features to stderr.
Definition koliseo.c:239
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.
Definition koliseo.c:2402
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.
Definition koliseo.c:1525
void print_dbg_kls(const Koliseo *kls)
Prints header fields from the passed Koliseo pointer, to stderr.
Definition koliseo.c:2018
const char * string_koliseo_version(void)
Returns current koliseo version as a string.
Definition koliseo.c:63
void * kls_repush(Koliseo *kls, void *old, ptrdiff_t size, ptrdiff_t align, ptrdiff_t old_count, ptrdiff_t new_count)
Takes a Koliseo pointer, and a void pointer to the old allocation, ptrdiff_t values for size,...
Definition koliseo.c:1631
KLS_Push_Result kls__advance(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t *padding, const char *caller_name)
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1106
char * kls_temp_vsprintf(Koliseo_Temp *kls_t, const char *fmt, va_list args)
Definition koliseo.c:1558
ptrdiff_t kls_get_pos(const Koliseo *kls)
Returns the current offset (position of pointer bumper) for the passed Koliseo.
Definition koliseo.c:292
Koliseo * kls_new_dbg_alloc_handled_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size, an allocation function pointer and a free function pointer,...
Definition koliseo.c:886
void KLS_ZEROCOUNT_Handler(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size)
Used to pass an error handler for zero-count push call error.
Definition koliseo.h:144
void kls_free(Koliseo *kls)
Calls kls_clear() on the passed Koliseo pointer and the frees the actual Koliseo.
Definition koliseo.c:2139
KLS_Conf kls_conf_init_handled(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, FILE *log_fp, const char *log_filepath, KLS_Err_Handlers err_handlers)
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS.
Definition koliseo.c:182
bool kls_contains_pointer(const Koliseo *kls, const void *ptr)
Takes a Koliseo pointer, and a void pointer to a memory region.
Definition koliseo.c:1605
Koliseo * kls_new_dbg_ext(ptrdiff_t size, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size.
Definition koliseo.c:935
#define KLS_MINOR
Represents current minor release.
Definition koliseo.h:88
char * kls_temp_sprintf(Koliseo_Temp *kls_t, const char *fmt,...)
Takes a Koliseo_Temp pointer, and a format cstring, plus varargs.
Definition koliseo.c:1584
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.
Definition koliseo.c:2431
void KLS_ZEROCOUNT_default_handler__(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size)
Used by default when no handler is passed.
Definition koliseo.c:158
Koliseo * kls_new_dbg_alloc_handled(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size, an allocation function pointer and a free function pointer,...
Definition koliseo.c:920
KLS_Push_Error kls__check_available(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.
Definition koliseo.c:1201
#define KLS_PATCH
Represents current patch release.
Definition koliseo.h:89
void * kls_alloc_func(size_t)
Used to select an allocation function for the arena's backing memory.
Definition koliseo.h:91
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.
Definition koliseo.c:1390
Koliseo * kls_new_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func)
Takes a ptrdiff_t size and a function pointer to the allocation function.
Definition koliseo.c:635
Koliseo * kls_new_dbg(ptrdiff_t size)
Takes a ptrdiff_t size and returns a pointer to the prepared Koliseo.
Definition koliseo.c:967
void KLS_hook_on_free(struct Koliseo *kls)
Used to pass an extension handler for kls_free().
Definition koliseo.h:185
Koliseo * kls_new_traced_alloc(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func)
Takes a ptrdiff_t size, a filepath for the trace output file, an allocation function pointer and a fr...
Definition koliseo.c:834
char * kls_sprintf(Koliseo *kls, const char *fmt,...)
Takes a Koliseo pointer, and a format cstring, plus varargs.
Definition koliseo.c:1497
void KLS_hook_on_temp_repush_last(struct Koliseo_Temp *t_kls, ptrdiff_t padding, const char *caller, void *user)
Used to pass an extension handler for kls_temp_repush() when extending the last allocation (otherwise...
Definition koliseo.h:197
void KLS_hook_on_temp_push(struct Koliseo_Temp *t_kls, ptrdiff_t padding, const char *caller, void *user)
Used to pass an extension handler for kls_temp_push().
Definition koliseo.h:195
Koliseo * kls_new_traced_handled(ptrdiff_t size, const char *output_path, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size and a filepath for the trace output file.
Definition koliseo.c:868
Koliseo * kls_new_conf_alloc(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, kls_free_func kls_free_func)
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, an allocation function pointer and a...
Definition koliseo.c:709
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.
Definition koliseo.c:2316
void KLS_hook_on_repush_last(struct Koliseo *kls, ptrdiff_t padding, const char *caller, void *user)
Used to pass an extension handler for kls_repush() when extending the last allocation (otherwise,...
Definition koliseo.h:189
void KLS_hook_on_temp_free(struct Koliseo_Temp *t_kls)
Used to pass an extension handler for kls_temp_end().
Definition koliseo.h:193
Koliseo * kls_new_conf_alloc_ext(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, an allocation function pointer and a...
Definition koliseo.c:680
void KLS_PTRDIFF_MAX_default_handler__(struct Koliseo *kls, ptrdiff_t size, ptrdiff_t count)
Used by default when no handler is passed.
Definition koliseo.c:116
void KLS_hook_on_push(struct Koliseo *kls, ptrdiff_t padding, const char *caller, void *user)
Used to pass an extension handler for kls_push().
Definition koliseo.h:187
KLS_Push_Error
Defines the result for kls__check_available().
Definition koliseo.h:372
@ KLS_PUSH_NEGATIVE_COUNT
Definition koliseo.h:377
@ KLS_PUSH_ZEROCOUNT
Definition koliseo.h:378
@ KLS_PUSH_ALIGN_NOT_POW2
Definition koliseo.h:376
@ KLS_PUSH_WITH_TEMP_ACTIVE
Definition koliseo.h:379
@ KLS_PUSH_OOM
Definition koliseo.h:381
@ KLS_PUSH_PTRDIFF_MAX
Definition koliseo.h:380
@ KLS_PUSH_SIZE_LT1
Definition koliseo.h:374
@ KLS_PUSH_ALIGN_LT1
Definition koliseo.h:375
@ KLS_PUSH_OK
Definition koliseo.h:373
KLS_Conf kls_conf_init(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, FILE *log_fp, const char *log_filepath)
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS.
Definition koliseo.c:230
KLS_Push_Result kls__temp_advance(Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t *padding, const char *caller_name)
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1261
void * kls__handle_push_result(Koliseo *kls, KLS_Push_Result r, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t padding, const char *caller_name)
Handles a KLS_Push_Result.
Definition koliseo.c:310
Koliseo * kls_new_alloc_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size and a function pointer to the allocation function.
Definition koliseo.c:545
void print_kls_2file(FILE *fp, const Koliseo *kls)
Prints header fields from the passed Koliseo pointer, to the passed FILE pointer.
Definition koliseo.c:1987
Koliseo * kls_new_traced_alloc_handled_ext(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size, a filepath for the trace output file, an allocation function pointer and a fr...
Definition koliseo.c:762
Koliseo * kls_new_dbg_handled(ptrdiff_t size, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size and returns a pointer to the prepared Koliseo.
Definition koliseo.c:982
void KLS_PTRDIFF_MAX_Handler(struct Koliseo *kls, ptrdiff_t size, ptrdiff_t count)
Used to pass an error handler for count > (PTRDIFF_MAX / size) error.
Definition koliseo.h:138
void kls_clear(Koliseo *kls)
Resets the offset field for the passed Koliseo pointer.
Definition koliseo.c:2107
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.
Definition koliseo.c:1423
#define KLS_MAJOR
Represents current major release.
Definition koliseo.h:87
int int_koliseo_version(void)
Returns current koliseo version as an integer.
Definition koliseo.c:72
Koliseo * kls_new_traced_ext(ptrdiff_t size, const char *output_path, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size and a filepath for the trace output file.
Definition koliseo.c:815
Koliseo * kls_new_conf(ptrdiff_t size, KLS_Conf conf)
Takes a ptrdiff_t size and a KLS_Conf to configure the new Koliseo.
Definition koliseo.c:742
Koliseo * kls_new_conf_ext(ptrdiff_t size, KLS_Conf conf, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size and a KLS_Conf to configure the new Koliseo.
Definition koliseo.c:726
Defines flags for Koliseo.
Definition koliseo.h:233
int growable
If set to 1, make the Koliseo grow when a out of memory for a push call.
Definition koliseo.h:240
int verbose_lvl
If > 0, makes the Koliseo try to acquire kls_log_fp from kls_log_filepath.
Definition koliseo.h:235
const char * log_filepath
String representing the path to the Koliseo logfile.
Definition koliseo.h:237
FILE * log_fp
FILE pointer used by the Koliseo to print its kls_log() output.
Definition koliseo.h:236
int allow_zerocount_push
If set to 1, make the Koliseo accept push calls with a count of 0.
Definition koliseo.h:239
int collect_stats
If set to 1, make the Koliseo collect performance stats.
Definition koliseo.h:234
KLS_Err_Handlers err_handlers
Used to pass custom error handlers for push calls.
Definition koliseo.h:241
int block_while_has_temp
If set to 1, make the Koliseo reject push calls while it has an open Koliseo_Temp.
Definition koliseo.h:238
Defines the handlers used for errors in push calls.
Definition koliseo.h:171
KLS_OOM_Handler * OOM_handler
Pointer to handler for Out-Of-Memory errors in push calls.
Definition koliseo.h:172
KLS_ZEROCOUNT_Handler * ZEROCOUNT_handler
Pointer to handler for zero-count errors in push calls.
Definition koliseo.h:174
KLS_PTRDIFF_MAX_Handler * PTRDIFF_MAX_handler
Pointer to handler for count > (PTRDIFF_MAX / size) errors in push calls.
Definition koliseo.h:173
Definition koliseo.h:199
KLS_hook_on_temp_start * on_temp_start_handler
Used to pass custom start handler for kls_temp_start calls.
Definition koliseo.h:204
KLS_hook_on_free * on_free_handler
Used to pass custom free handler for kls_free calls.
Definition koliseo.h:201
KLS_hook_on_repush_last * on_repush_last_handler
Used to pass custom push handler for kls_repush calls that extend the last allocation (otherwise,...
Definition koliseo.h:203
KLS_hook_on_temp_free * on_temp_free_handler
Used to pass custom free handler for kls_temp_end calls.
Definition koliseo.h:205
KLS_hook_on_push * on_push_handler
Used to pass custom push handler for kls_push calls.
Definition koliseo.h:202
KLS_hook_on_new * on_new_handler
Used to pass custom new handler for kls_new_alloc calls.
Definition koliseo.h:200
KLS_hook_on_temp_push * on_temp_push_handler
Used to pass custom push handler for kls_temp_push calls.
Definition koliseo.h:206
KLS_hook_on_temp_repush_last * on_temp_repush_last_handler
Used to pass custom push handler for kls_temp_repush calls that extend the last allocation (otherwise...
Definition koliseo.h:207
Defines the result for kls__advance() and kls__temp_advance().
Definition koliseo.h:389
KLS_Push_Error error
Definition koliseo.h:391
void * p
Definition koliseo.h:390
Defines a stat struct for Koliseo.
Definition koliseo.h:254
int tot_pops
Total POP calls done.
Definition koliseo.h:257
double worst_pushcall_time
DEPRECATED: support for timing will be dropped in the next release.
Definition koliseo.h:264
int tot_temp_pushes
Total PUSH_T calls done.
Definition koliseo.h:256
int tot_pushes
Total PUSH calls done.
Definition koliseo.h:255
int tot_logcalls
Total kls_log() calls done.
Definition koliseo.h:259
int tot_temp_pops
Total POP_T calls done.
Definition koliseo.h:258
Represents a savestate for a Koliseo.
Definition koliseo.h:361
ptrdiff_t offset
Current position of memory pointer.
Definition koliseo.h:363
ptrdiff_t prev_offset
Previous position of memory pointer.
Definition koliseo.h:364
Koliseo * kls
Reference to the actual Koliseo we're saving.
Definition koliseo.h:362
Represents the initialised arena allocator struct.
Definition koliseo.h:322
ptrdiff_t size
Size of data field.
Definition koliseo.h:324
ptrdiff_t offset
Current position of memory pointer.
Definition koliseo.h:325
ptrdiff_t prev_offset
Previous position of memory pointer.
Definition koliseo.h:326
KLS_Conf conf
Contains flags to change the Koliseo behaviour.
Definition koliseo.h:328
struct Koliseo_Temp * t_kls
Points to related active Kolieo_Temp, when has_temp == 1.
Definition koliseo.h:330
KLS_Hooks hooks
Contains handlers for extensions.
Definition koliseo.h:331
char * data
Points to data field.
Definition koliseo.h:323
size_t hooks_len
Length for hooks and extension_data.
Definition koliseo.h:333
struct Koliseo * next
Points to the next Koliseo when conf.growable == 1.
Definition koliseo.h:335
void * extension_data
Points to data for extensions.
Definition koliseo.h:332
int has_temp
When == 1, a Koliseo_Temp is currently active on this Koliseo.
Definition koliseo.h:327
KLS_Stats stats
Contains stats for Koliseo performance analysis.
Definition koliseo.h:329
kls_free_func * free_func
Points to the free function for the arena's backing memory.
Definition koliseo.h:334