summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-14 07:53:50 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-17 12:03:45 +0300
commit9c3f1dd6ee81e5fcb1a1838f1235bdc3e6f1e641 (patch)
tree1ef820febeb4b92c299cabcd405894ee268e4c5d /include
parent2f59089f738b9eed6bcb98da5d507ebb4b2c3075 (diff)
downloadbdwgc-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 'include')
-rw-r--r--include/gc/leak_detector.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/gc/leak_detector.h b/include/gc/leak_detector.h
index 93934216..9950d738 100644
--- a/include/gc/leak_detector.h
+++ b/include/gc/leak_detector.h
@@ -66,6 +66,11 @@
#undef posix_memalign
#define posix_memalign(p,a,n) GC_posix_memalign(p,a,n)
+#undef _aligned_malloc
+#define _aligned_malloc(n,a) GC_memalign(a,n) /* reverse args order */
+#undef _aligned_free
+#define _aligned_free(p) GC_free(GC_base(p)) /* non-debug */
+
#ifndef GC_NO_VALLOC
# undef valloc
# define valloc(n) GC_valloc(n)