From 54c36a38b1b30055133d46a8fe2f69a73f8284c4 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 8 Aug 2021 00:11:49 +0200 Subject: [PATCH] ialloc: Prepare for allocation-deallocation checking. * lib/ialloc.h (imalloc, irealloc, icalloc): Add comment that deallocation must happen through 'free'. --- ChangeLog | 6 ++++++ lib/ialloc.h | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index be558220e8..0355389b85 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-08-07 Bruno Haible + + ialloc: Prepare for allocation-deallocation checking. + * lib/ialloc.h (imalloc, irealloc, icalloc): Add comment that + deallocation must happen through 'free'. + 2021-08-07 Bruno Haible aligned-malloc: Prepare for allocation-deallocation checking. diff --git a/lib/ialloc.h b/lib/ialloc.h index ebe4aaa3cf..5ceda4633a 100644 --- a/lib/ialloc.h +++ b/lib/ialloc.h @@ -43,13 +43,17 @@ _gl_alloc_nomem (void) return NULL; } -IALLOC_INLINE void * +IALLOC_INLINE +_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ +void * imalloc (idx_t s) { return s <= SIZE_MAX ? malloc (s) : _gl_alloc_nomem (); } -IALLOC_INLINE void * +IALLOC_INLINE +/*_GL_ATTRIBUTE_DEALLOC_FREE*/ +void * irealloc (void *p, idx_t s) { /* Work around GNU realloc glitch by treating a zero size as if it @@ -57,7 +61,9 @@ irealloc (void *p, idx_t s) return s <= SIZE_MAX ? realloc (p, s | !s) : _gl_alloc_nomem (); } -IALLOC_INLINE void * +IALLOC_INLINE +_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/ +void * icalloc (idx_t n, idx_t s) { if (SIZE_MAX < n) -- 2.39.5