From 897a153d290ed4d3647ad9e0100d1b717f580b5f Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Tue, 12 May 2026 16:41:37 -0400 Subject: typedef all structs and rename to Ada_Case There isn't really a technical reason that I made this change. I just wanted to use Ada_Case. All types were prefixed with ty_, e.g. ty_Image. --- teensy/teensy_mem.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'teensy/teensy_mem.c') diff --git a/teensy/teensy_mem.c b/teensy/teensy_mem.c index 62088b8..7e8dd58 100644 --- a/teensy/teensy_mem.c +++ b/teensy/teensy_mem.c @@ -14,16 +14,16 @@ uint8_t *next_temp_alloc = temp_arena; #define BACKTRACE_SIZE 16 -struct alloc { +typedef struct { void *ptr; size_t size; int backtrace_len; char **backtrace; -}; +} Alloc; int allocations_cap; int allocations_len; -struct alloc *allocations; +Alloc *allocations; #endif // TODO TEENSY_DEBUG @@ -32,7 +32,7 @@ void ty_init_mem(void) #ifdef TEENSY_DEBUG allocations_len = 0; allocations_cap = 8; - allocations = malloc(sizeof(struct alloc) * 8); + allocations = malloc(sizeof(Alloc) * 8); if (!allocations) ty_log_fatal(TY_ERR_MEM, "(%s) (track) ran out of memory", __func__); #endif // TEENSY_DEBUG @@ -43,7 +43,7 @@ void ty_deinit_mem(void) #ifdef TEENSY_DEBUG fprintf(stderr, "%d allocations leaked\n", allocations_len); for (int i = 0; i < allocations_len; i++) { - struct alloc *alloc = &allocations[i]; + Alloc *alloc = &allocations[i]; fprintf( stderr, "leaked %zu bytes at %p\n", @@ -87,7 +87,7 @@ void *ty_alloc(size_t size) #ifdef TEENSY_DEBUG // Log allocation - struct alloc alloc; + Alloc alloc; void *bt[BACKTRACE_SIZE]; int bt_len = backtrace(bt, BACKTRACE_SIZE); char **symbols = backtrace_symbols(bt, bt_len); @@ -130,7 +130,7 @@ void *ty_realloc(void *ptr, size_t new_size) #ifdef TEENSY_DEBUG for (int i = 0; i < allocations_len; i++) { - struct alloc *alloc = &allocations[i]; + Alloc *alloc = &allocations[i]; if (alloc->ptr == ptr) { alloc->ptr = new_ptr; alloc->size = new_size; @@ -148,7 +148,7 @@ void ty_free(void *ptr) bool double_free = true; for (int i = 0; i < allocations_len; i++) { - struct alloc *alloc = &allocations[i]; + Alloc *alloc = &allocations[i]; if (alloc->ptr == ptr) { free(alloc->backtrace); *alloc = allocations[allocations_len - 1]; -- cgit v1.3-2-g0d8e