Use a custom allocator for everything.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3892 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-06-04 17:04:51 +00:00
parent cf61e68713
commit 9c90b2bc1d
24 changed files with 404 additions and 343 deletions

View File

@ -1,7 +1,8 @@
#include "trace.h"
#include "mem.h"
#include <assert.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
@ -56,7 +57,7 @@ static void _trace_append(tf_trace_t* trace, const char* buffer, size_t size, vo
tf_trace_t* tf_trace_create()
{
tf_trace_t* trace = malloc(sizeof(tf_trace_t));
tf_trace_t* trace = tf_malloc(sizeof(tf_trace_t));
memset(trace, 0, sizeof(*trace));
trace->callback = _trace_append;
return trace;
@ -68,9 +69,9 @@ void tf_trace_destroy(tf_trace_t* trace)
{
tf_trace_stack_t* stack = trace->stack;
trace->stack = stack->next;
free(stack);
tf_free(stack);
}
free(trace);
tf_free(trace);
}
void tf_trace_raw(tf_trace_t* trace, const char* buffer, size_t size)
@ -116,7 +117,7 @@ void tf_trace_begin(tf_trace_t* trace, const char* name)
if (!trace->stack || trace->stack->count + 1 > _countof(trace->stack->names))
{
tf_trace_stack_t* stack = malloc(sizeof(tf_trace_stack_t));
tf_trace_stack_t* stack = tf_malloc(sizeof(tf_trace_stack_t));
memset(stack, 0, sizeof(*stack));
stack->next = trace->stack;
trace->stack = stack;
@ -205,7 +206,7 @@ char* tf_trace_export(tf_trace_t* trace)
}
static const int k_extra_size = 1024;
char* buffer = malloc(k_buffer_size + k_extra_size);
char* buffer = tf_malloc(k_buffer_size + k_extra_size);
const char* newline = strchr(trace->buffer + trace->write_offset, '\n');
int begin = newline ? newline - trace->buffer : 0;
size_t size = 0;