From ff7a4cb0cb07c9f864e62bed4d3a0fe4ce2a30d1 Mon Sep 17 00:00:00 2001 From: dzaima Date: Thu, 7 Apr 2022 01:19:35 +0300 Subject: [PATCH] error on non-functional malloc_usable_size --- src/opt/mm_malloc.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/opt/mm_malloc.h b/src/opt/mm_malloc.h index 718ea702..a7e7322b 100644 --- a/src/opt/mm_malloc.h +++ b/src/opt/mm_malloc.h @@ -33,5 +33,9 @@ void mm_forHeap(V2v f); void mm_dumpHeap(FILE* f); static u64 mm_round(usz x) { return x; } -static u64 mm_size(Value* x) { return malloc_usable_size(x); } +static u64 mm_size(Value* x) { + size_t r = malloc_usable_size(x); + if (((ssize_t)r) < 16) err("MM=0 requires working malloc_usable_size"); + return r; +} static u64 mm_totalAllocated() { return -1; }