config/Data: add method Clear()

Move code from config_global_finish().
This commit is contained in:
Max Kellermann 2015-01-21 21:50:02 +01:00
parent f80ab6a7a2
commit f900ab0121
4 changed files with 34 additions and 4 deletions

View File

@ -769,7 +769,7 @@ endif
libconf_a_SOURCES = \
src/config/ConfigDefaults.hxx \
src/config/ConfigPath.cxx src/config/ConfigPath.hxx \
src/config/Data.hxx \
src/config/Data.cxx src/config/Data.hxx \
src/config/Block.cxx src/config/Block.hxx \
src/config/Param.cxx src/config/Param.hxx \
src/config/ConfigParser.cxx src/config/ConfigParser.hxx \

View File

@ -37,9 +37,7 @@ static ConfigData config_data;
void config_global_finish(void)
{
for (auto i : config_data.params)
delete i;
config_data.params.fill(0);
config_data.Clear();
}
void config_global_init(void)

30
src/config/Data.cxx Normal file
View File

@ -0,0 +1,30 @@
/*
* Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "Data.hxx"
#include "Param.hxx"
void
ConfigData::Clear()
{
for (auto i : params)
delete i;
params.fill(nullptr);
}

View File

@ -28,6 +28,8 @@ struct config_param;
struct ConfigData {
std::array<config_param *, std::size_t(CONF_MAX)> params;
void Clear();
};
#endif