From: Alan T. DeKok Date: Tue, 5 Apr 2022 12:31:14 +0000 (-0400) Subject: add fr_pair_init_null() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81471b404517937dda364110cb2fedea0abe11f6;p=thirdparty%2Ffreeradius-server.git add fr_pair_init_null() because memset(vp, 0) is no longer appropriate --- diff --git a/src/lib/util/pair.c b/src/lib/util/pair.c index 7e933e5ca6..cdcfdd66ba 100644 --- a/src/lib/util/pair.c +++ b/src/lib/util/pair.c @@ -115,6 +115,17 @@ static inline CC_HINT(always_inline) void pair_init_null(fr_pair_t *vp) vp->op = T_OP_EQ; } +/** Initialise fields in an fr_pair_t without assigning a da + * + * Used only for temporary value-pairs which are not placed in any list. + */ +void fr_pair_init_null(fr_pair_t *vp) +{ + memset(vp, 0, sizeof(*vp)); + + pair_init_null(vp); +} + /** Dynamically allocate a new attribute with no #fr_dict_attr_t assigned * * This is not the function you're looking for (unless you're binding diff --git a/src/lib/util/pair.h b/src/lib/util/pair.h index a85ce47e90..7c23023fdb 100644 --- a/src/lib/util/pair.h +++ b/src/lib/util/pair.h @@ -186,6 +186,8 @@ DIAG_ON(nonnull-compare) /* Initialisation */ void fr_pair_list_init(fr_pair_list_t *head) CC_HINT(nonnull); +void fr_pair_init_null(fr_pair_t *vp) CC_HINT(nonnull); + /* Allocation and management */ fr_pair_t *fr_pair_alloc_null(TALLOC_CTX *ctx) CC_HINT(warn_unused_result);