[PATCH 1/2] Added NJS_MALLOC().

Alejandro Colomar alx.manpages at gmail.com
Mon Jan 30 13:35:53 UTC 2023


This attribute helps avoid memory leaks.

Link: <https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute>
Cc: Liam Crilly <liam at nginx.com>
Cc: Zhidao Hong <z.hong at f5.com>
Signed-off-by: Alejandro Colomar <alx at nginx.com>
---
 src/njs_clang.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/njs_clang.h b/src/njs_clang.h
index 614b509..c52d75a 100644
--- a/src/njs_clang.h
+++ b/src/njs_clang.h
@@ -155,10 +155,12 @@ njs_leading_zeros64(uint64_t x)
 
 
 #if (NJS_HAVE_GCC_ATTRIBUTE_MALLOC)
-#define NJS_MALLOC_LIKE    __attribute__((__malloc__))
+#define NJS_MALLOC_LIKE          __attribute__((__malloc__))
+#define NJS_MALLOC(deallocator)  __attribute__((__malloc__(deallocator)))
 
 #else
 #define NJS_MALLOC_LIKE
+#define NJS_MALLOC(deallocator)
 #endif
 
 
-- 
2.39.0


More information about the nginx-devel mailing list