]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add and use MALLOCX_ZERO_GET() macro to jemalloc_shim.h
authorOndřej Surý <ondrej@isc.org>
Wed, 4 Jun 2025 08:19:35 +0000 (10:19 +0200)
committerOndřej Surý <ondrej@isc.org>
Mon, 30 Jun 2025 11:22:39 +0000 (13:22 +0200)
Pull MALLOCX_ZERO_GET() macro to align the usage with the jemalloc
jemalloc/internal/jemalloc_internal_types.h header.

lib/isc/jemalloc_shim.h

index 55bab911d1ab0b0b8c467055ef5eb5df58e1ee40..ef892f031881f6cf2813f6a4071c70b7190a7696 100644 (file)
 
 const char *malloc_conf = NULL;
 
-#define MALLOCX_ZERO ((int)0x40)
+/*
+ * The MALLOCX_ZERO and MALLOCX_ZERO_GET macros were taken literal from
+ * jemalloc_macros.h and jemalloc_internal_types.h headers respectively.
+ */
+
+#define MALLOCX_ZERO           ((int)0x40)
+#define MALLOCX_ZERO_GET(flags) ((bool)(flags & MALLOCX_ZERO))
 
 typedef union {
        size_t size;
@@ -42,7 +48,7 @@ mallocx(size_t size, int flags) {
        si->size = size;
        ptr = &si[1];
 
-       if ((flags & MALLOCX_ZERO) != 0) {
+       if (MALLOCX_ZERO_GET(flags)) {
                memset(ptr, 0, size);
        }
 
@@ -68,7 +74,7 @@ rallocx(void *ptr, size_t size, int flags) {
        size_info *si = realloc(&(((size_info *)ptr)[-1]), size + sizeof(*si));
        INSIST(si != NULL);
 
-       if ((flags & MALLOCX_ZERO) != 0 && size > si->size) {
+       if (MALLOCX_ZERO_GET(flags) && size > si->size) {
                memset((uint8_t *)si + sizeof(*si) + si->size, 0,
                       size - si->size);
        }