aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_mem.c
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-24 09:04:26 -0400
committeriamcheeseman <[email protected]>2026-05-24 09:04:26 -0400
commitbcf1439eb8d936d3b43ac817519cd47e9624210e (patch)
tree056cf005b5f304d1e58ce34e157d4e78d8ef0667 /teensy/teensy_mem.c
parentfc3ad3fec91ba54414cc5cb126d61803611056f3 (diff)
completely redo lists
Diffstat (limited to 'teensy/teensy_mem.c')
-rw-r--r--teensy/teensy_mem.c19
1 files changed, 19 insertions, 0 deletions
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
+}