[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ialloc: Prepare for allocation-deallocation checking
From: |
Bruno Haible |
Subject: |
ialloc: Prepare for allocation-deallocation checking |
Date: |
Sun, 08 Aug 2021 00:12:32 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; ) |
As mentioned in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-08/msg00092.html>,
I believe the attribute will someday be supported also on inline functions.
2021-08-07 Bruno Haible <bruno@clisp.org>
ialloc: Prepare for allocation-deallocation checking.
* lib/ialloc.h (imalloc, irealloc, icalloc): Add comment that
deallocation must happen through 'free'.
diff --git a/lib/ialloc.h b/lib/ialloc.h
index ebe4aaa..5ceda46 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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- ialloc: Prepare for allocation-deallocation checking,
Bruno Haible <=