]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pools: add pool_zalloc() to return a zeroed area
authorWilly Tarreau <w@1wt.eu>
Mon, 22 Mar 2021 21:05:05 +0000 (22:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 22 Mar 2021 21:05:05 +0000 (22:05 +0100)
It's like pool_alloc() but the output is zeroed before being returned
and is never poisonned.

include/haproxy/pool.h

index b37fb9d3e139169ec2fc633602687efcda64f8e1..ce13710378b52706c181333dd59fd421e5ae93e7 100644 (file)
@@ -325,6 +325,15 @@ static inline void *pool_alloc(struct pool_head *pool)
        return __pool_alloc(pool, 0);
 }
 
+/*
+ * Returns a pointer to type <type> taken from the pool <pool_type> or
+ * dynamically allocated. The area is zeroed.
+ */
+static inline void *pool_zalloc(struct pool_head *pool)
+{
+       return __pool_alloc(pool, POOL_F_MUST_ZERO);
+}
+
 /*
  * Puts a memory area back to the corresponding pool.
  * Items are chained directly through a pointer that