From: Arran Cudbard-Bell Date: Thu, 15 Jun 2017 13:58:39 +0000 (-0400) Subject: Mark up allocated subsections with the talloc type if one is set X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aadbb4d176fa1daf73a3a8dca680c475f7049aec;p=thirdparty%2Ffreeradius-server.git Mark up allocated subsections with the talloc type if one is set --- diff --git a/src/include/cf_parse.h b/src/include/cf_parse.h index b3b35964b06..289cc4bfba6 100644 --- a/src/include/cf_parse.h +++ b/src/include/cf_parse.h @@ -427,6 +427,7 @@ struct CONF_PARSER { //!< #CONF_PARSER structs, forming the subsection. size_t subcs_size; //!< If non-zero, allocate structs of this size to hold //!< the parsed data. + char const *subcs_type; //!< Set a specific talloc type for subcs structures. }; }; diff --git a/src/main/cf_parse.c b/src/main/cf_parse.c index bb470851ff7..b352bbe4420 100644 --- a/src/main/cf_parse.c +++ b/src/main/cf_parse.c @@ -896,7 +896,10 @@ static int cf_subsection_parse(TALLOC_CTX *ctx, void *out, CONF_SECTION *cs, CON */ if (!subcs_size) return cf_section_parse(ctx, out, subcs); - if (out) MEM(buff = talloc_array(ctx, uint8_t, subcs_size)); + if (out) { + MEM(buff = talloc_array(ctx, uint8_t, subcs_size)); + if (rule->subcs_type) talloc_set_name_const(buff, rule->subcs_type); + } ret = cf_section_parse(buff, buff, subcs); if (ret < 0) { @@ -918,8 +921,10 @@ static int cf_subsection_parse(TALLOC_CTX *ctx, void *out, CONF_SECTION *cs, CON /* * Allocate an array to hold the subsections */ - if (out) MEM(array = talloc_array(ctx, uint8_t *, count)); - + if (out) { + MEM(array = talloc_array(ctx, uint8_t *, count)); + if (rule->subcs_type) talloc_set_name(array, "%s *", rule->subcs_type); + } /* * Start parsing... * @@ -937,6 +942,7 @@ static int cf_subsection_parse(TALLOC_CTX *ctx, void *out, CONF_SECTION *cs, CON if (array) { MEM(buff = talloc_zero_array(array, uint8_t, subcs_size)); + if (rule->subcs_type) talloc_set_name_const(buff, rule->subcs_type); array[i] = buff; }