From 1e6ed8db68ee6b4bb825eaa12cbc474d29e63d95 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 30 Dec 2009 17:34:58 +0100 Subject: [PATCH] Move getLoggingClasses() result buffer to file level. Getting it out of the function fixes some corruption problems at program exit. --- src/Main/fg_props.cxx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 066f0262b..31f4ae0da 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -85,20 +85,26 @@ LogClassMapping log_class_mappings [] = { /** * Get the logging classes. */ +// XXX Making the result buffer be global is a band-aid that hopefully +// delays its destruction 'til after its last use. +namespace +{ +string loggingResult; +} + static const char * getLoggingClasses () { sgDebugClass classes = logbuf::get_log_classes(); - static string result; - result = ""; + loggingResult.clear(); for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) { if ((classes&log_class_mappings[i].c) > 0) { - if (!result.empty()) - result += '|'; - result += log_class_mappings[i].name; + if (!loggingResult.empty()) + loggingResult += '|'; + loggingResult += log_class_mappings[i].name; } } - return result.c_str(); + return loggingResult.c_str(); }