Commit 7562c575 authored by Max Kellermann's avatar Max Kellermann

db/Configured: allocate ConfigBlock on the stack

parent e6e7d6db
......@@ -43,16 +43,13 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
return nullptr;
}
ConfigBlock *allocated = nullptr;
if (param == nullptr && path != nullptr) {
allocated = new ConfigBlock(path->line);
allocated->AddBlockParam("path", path->value.c_str(),
path->line);
param = allocated;
}
if (param == nullptr) {
if (param != nullptr)
return DatabaseGlobalInit(loop, listener, *param, error);
else if (path != nullptr) {
ConfigBlock block(path->line);
block.AddBlockParam("path", path->value.c_str(), path->line);
return DatabaseGlobalInit(loop, listener, block, error);
} else {
/* if there is no override, use the cache directory */
const AllocatedPath cache_dir = GetUserCacheDir();
......@@ -65,13 +62,8 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
if (db_file_utf8.empty())
return nullptr;
allocated = new ConfigBlock();
allocated->AddBlockParam("path", db_file_utf8.c_str(), -1);
param = allocated;
ConfigBlock block;
block.AddBlockParam("path", db_file_utf8.c_str(), -1);
return DatabaseGlobalInit(loop, listener, block, error);
}
Database *db = DatabaseGlobalInit(loop, listener, *param,
error);
delete allocated;
return db;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment