release the include directive if found in config
authorJim Morris <morris@wolfman.com>
Wed, 1 Mar 2017 06:09:02 +0000 (22:09 -0800)
committerJim Morris <morris@wolfman.com>
Wed, 1 Mar 2017 06:09:02 +0000 (22:09 -0800)
src/libs/ConfigCache.cpp
src/libs/ConfigCache.h
src/libs/ConfigSources/FileConfigSource.cpp

index 20f6b47..44d307f 100644 (file)
@@ -26,6 +26,13 @@ void ConfigCache::add(ConfigValue *v)
     store.push_back(v);
 }
 
+void ConfigCache::pop()
+{
+    auto cv= store.back();
+    store.pop_back();
+    delete cv;
+}
+
 // If we find an existing value, replace it, otherwise, push it at the back of the list
 void ConfigCache::replace_or_push_back(ConfigValue *new_value)
 {
index 375d712..d767dda 100644 (file)
@@ -23,6 +23,7 @@ class ConfigCache {
         void clear();
 
         void add(ConfigValue* v);
+        void pop();
 
         // lookup and return the entru that matches the check sums,return NULL if not found
         ConfigValue *lookup(const uint16_t *check_sums) const;
index ce0cc2b..4807d50 100644 (file)
@@ -80,6 +80,8 @@ void FileConfigSource::transfer_values_to_cache( ConfigCache *cache, const char
             // if this line is an include directive then attempt to read the included file
             if(cv->check_sums[0] == include_checksum) {
                 string inc_file_name = cv->value.c_str();
+                cache->pop(); // we do not need to keep this around or leave it on the list
+
                 if(!file_exists(inc_file_name)) {
                     // if the file is not found at the location entered then look around for it a bit
                     if(inc_file_name[0] != '/') inc_file_name = "/" + inc_file_name;