Welcome! Log In Create A New Profile

Advanced

[PATCH 1/2] Added NJS_MALLOC().

Alejandro Colomar
January 30, 2023 08:38AM
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@nginx.com>
Cc: Zhidao Hong <z.hong@f5.com>
Signed-off-by: Alejandro Colomar <alx@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
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 1/2] Added NJS_MALLOC().

Alejandro Colomar 366 January 30, 2023 08:38AM

[PATCH 2/2] Using NJS_MALLOC() in functions that create new objects.

Alejandro Colomar 116 January 30, 2023 08:38AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 256
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready