From bcf1439eb8d936d3b43ac817519cd47e9624210e Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Sun, 24 May 2026 09:04:26 -0400 Subject: completely redo lists --- teensy/teensy_mem.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'teensy/teensy_mem.c') diff --git a/teensy/teensy_mem.c b/teensy/teensy_mem.c index 8c1022d..65b7486 100644 --- a/teensy/teensy_mem.c +++ b/teensy/teensy_mem.c @@ -126,6 +126,11 @@ void *ty_realloc(void *ptr, size_t new_size) return NULL; } + // The pointer will not be registered in the tracker by realloc if it does + // not yet exist. + if (ptr == NULL) + return ty_alloc(new_size); + void *new_ptr = realloc(ptr, new_size); if (!new_ptr) ty_log_fatal(TY_ERR_MEM, "(%s) ran out of memory", __func__); @@ -179,3 +184,17 @@ int ty_alloc_count(void) return -1; #endif } + +size_t ty_alloc_size(void) +{ +#ifdef TEENSY_DEBUG + size_t total = 0; + for (int i = 0; i < allocations_len; i++) { + Alloc *alloc = &allocations[i]; + total += alloc->size; + } + return total; +#else + return 0; +#endif +} -- cgit v1.3-2-g0d8e