From 9c3f1dd6ee81e5fcb1a1838f1235bdc3e6f1e641 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 14 Apr 2023 07:53:50 +0300 Subject: Redirect _aligned_malloc/free() in leak_detector.h * include/gc/leak_detector.h (_aligned_malloc, _aligned_free): Redefine macro. * include/gc/leak_detector.h (_aligned_free): Use GC_base (because GC_memalign might return a pointer inside the allocated object to ensure the requested alignment). * tests/leak.c (main): Call _aligned_malloc() and _aligned_free(); print error and exit in case of _aligned_malloc() failure. --- tests/leak.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/leak.c b/tests/leak.c index dc2fb8fa..2cfb2507 100644 --- a/tests/leak.c +++ b/tests/leak.c @@ -15,6 +15,13 @@ int main(void) { GC_INIT(); /* Needed if thread-local allocation is enabled. */ /* FIXME: This is not ideal. */ + p[0] = (char *)_aligned_malloc(70 /* size */, 16); + if (!p[0]) { + fprintf(stderr, "Aligned allocation failed\n"); + return 1; + } + _aligned_free(p[0]); + for (i = 0; i < N_TESTS; ++i) { p[i] = i > 0 ? (char*)malloc(sizeof(int)+i) : strdup("abc"); -- cgit v1.2.1