diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-04-14 07:53:50 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-04-17 12:03:45 +0300 |
commit | 9c3f1dd6ee81e5fcb1a1838f1235bdc3e6f1e641 (patch) | |
tree | 1ef820febeb4b92c299cabcd405894ee268e4c5d /tests | |
parent | 2f59089f738b9eed6bcb98da5d507ebb4b2c3075 (diff) | |
download | bdwgc-9c3f1dd6ee81e5fcb1a1838f1235bdc3e6f1e641.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/leak.c | 7 |
1 files changed, 7 insertions, 0 deletions
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"); |