db/Configured: allocate ConfigBlock on the stack
This commit is contained in:
parent
e6e7d6dbd6
commit
7562c5751c
@ -43,16 +43,13 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigBlock *allocated = nullptr;
|
if (param != nullptr)
|
||||||
|
return DatabaseGlobalInit(loop, listener, *param, error);
|
||||||
if (param == nullptr && path != nullptr) {
|
else if (path != nullptr) {
|
||||||
allocated = new ConfigBlock(path->line);
|
ConfigBlock block(path->line);
|
||||||
allocated->AddBlockParam("path", path->value.c_str(),
|
block.AddBlockParam("path", path->value.c_str(), path->line);
|
||||||
path->line);
|
return DatabaseGlobalInit(loop, listener, block, error);
|
||||||
param = allocated;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if (param == nullptr) {
|
|
||||||
/* if there is no override, use the cache directory */
|
/* if there is no override, use the cache directory */
|
||||||
|
|
||||||
const AllocatedPath cache_dir = GetUserCacheDir();
|
const AllocatedPath cache_dir = GetUserCacheDir();
|
||||||
@ -65,13 +62,8 @@ CreateConfiguredDatabase(EventLoop &loop, DatabaseListener &listener,
|
|||||||
if (db_file_utf8.empty())
|
if (db_file_utf8.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
allocated = new ConfigBlock();
|
ConfigBlock block;
|
||||||
allocated->AddBlockParam("path", db_file_utf8.c_str(), -1);
|
block.AddBlockParam("path", db_file_utf8.c_str(), -1);
|
||||||
param = allocated;
|
return DatabaseGlobalInit(loop, listener, block, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Database *db = DatabaseGlobalInit(loop, listener, *param,
|
|
||||||
error);
|
|
||||||
delete allocated;
|
|
||||||
return db;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user