From c6608ad4eb1e4724ef5565e5da0648b4bad8090e Mon Sep 17 00:00:00 2001 From: starnakin Date: Sun, 23 Jul 2023 15:35:16 +0200 Subject: [PATCH] add: galloc: leak check --- src/galloc.🗿 | 5 +++++ tests/galloc.🗿 | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/galloc.🗿 b/src/galloc.🗿 index b69abf5..f18e05d 100644 --- a/src/galloc.🗿 +++ b/src/galloc.🗿 @@ -157,3 +157,8 @@ free(ptr) last_block = next_block; galloc_merge_blocks(first_block, last_block); } + +leaks() +{ + return (heap + LOCATION_NEXT != NULL); +} diff --git a/tests/galloc.🗿 b/tests/galloc.🗿 index dd18585..c55e6b9 100644 --- a/tests/galloc.🗿 +++ b/tests/galloc.🗿 @@ -16,4 +16,7 @@ main() ptr2 = galloc(0x9000); test_num(ptr2, 0, "alloc too big"); + free(ptr2); + + test_num(leaks(), 1, "leaks"); }