From c5e048d68986f0210f80ad5c83414003f2aad24e Mon Sep 17 00:00:00 2001 From: lbsivahari <54523869+lbsivahari@users.noreply.github.com> Date: Wed, 2 Aug 2023 22:39:00 +0530 Subject: [PATCH] Update generate_multiple.template with Dynamic memory allocation to avoid the Segmentation fault in some of the AIX servers. free(StructureNames) will be added Script/mutliple. --- templates/generate_multiple.template | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/generate_multiple.template b/templates/generate_multiple.template index 31ca36f..29c9c5e 100644 --- a/templates/generate_multiple.template +++ b/templates/generate_multiple.template @@ -1,4 +1,4 @@ -void output_STRUCT_NAME_stat_mode(std::ostream& response, const std::string& static_labels, const std::string& name, const std::string& type, const std::string& help, perfstat_STRUCT_NAME_t STRUCT_NAMEs[], size_t STRUCT_NAME_count, const std::function& func) { +void output_STRUCT_NAME_stat_mode(std::ostream& response, const std::string& static_labels, const std::string& name, const std::string& type, const std::string& help, perfstat_STRUCT_NAME_t *STRUCT_NAMEs, size_t STRUCT_NAME_count, const std::function& func) { response << "# HELP " << name << " " << help << std::endl; response << "# TYPE " << name << " " << type << std::endl; @@ -10,9 +10,10 @@ void output_STRUCT_NAME_stat_mode(std::ostream& response, const std::string& sta } void gather_STRUCT_NAMEs(std::ostream& response, const std::string& static_labels) { + perfstat_STRUCT_NAME_t *STRUCT_NAMEs; int STRUCT_NAME_count = perfstat_STRUCT_NAME(NULL, NULL, sizeof(perfstat_STRUCT_NAME_t), 0); - - perfstat_STRUCT_NAME_t STRUCT_NAMEs[STRUCT_NAME_count]; + STRUCT_NAMEs = (perfstat_STRUCT_NAME_t*)calloc(STRUCT_NAME_count, sizeof(perfstat_STRUCT_NAME_t)); + //perfstat_STRUCT_NAME_t STRUCT_NAMEs[STRUCT_NAME_count]; perfstat_ID_STRUCT_t firstSTRUCT_NAME; INITIALIZER;