Fix lmdb collections backend

This commit is contained in:
Felipe Zimmerle 2016-12-30 16:01:35 -03:00
parent b12cc91289
commit e181cb7e0a
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -188,6 +188,7 @@ std::string* LMDB::resolveFirst(const std::string& var) {
goto end_get; goto end_get;
} }
//FIXME: Memory leak here.
ret = new std::string( ret = new std::string(
reinterpret_cast<char *>(mdb_value_ret.mv_data), reinterpret_cast<char *>(mdb_value_ret.mv_data),
mdb_value_ret.mv_size); mdb_value_ret.mv_size);
@ -289,7 +290,9 @@ void LMDB::resolveSingleMatch(const std::string& var,
std::string *a = new std::string( std::string *a = new std::string(
reinterpret_cast<char *>(mdb_value_ret.mv_data), reinterpret_cast<char *>(mdb_value_ret.mv_data),
mdb_value_ret.mv_size); mdb_value_ret.mv_size);
l->push_back(new Variable(var, *a)); Variable *v = new Variable(&var, a);
v->m_dynamic_value = true;
l->push_back(v);
} }
mdb_cursor_close(cursor); mdb_cursor_close(cursor);
@ -502,10 +505,13 @@ void LMDB::resolveMultiMatches(const std::string& var,
if (strncmp(var.c_str(), a, keySize) != 0) { if (strncmp(var.c_str(), a, keySize) != 0) {
continue; continue;
} }
l->insert(l->begin(), new Variable( Variable *v = new Variable(
std::string(reinterpret_cast<char *>(key.mv_data), key.mv_size), new std::string(reinterpret_cast<char *>(key.mv_data),
std::string(reinterpret_cast<char *>(data.mv_data), key.mv_size),
data.mv_size))); new std::string(reinterpret_cast<char *>(data.mv_data),
data.mv_size));
v->m_dynamic_value = true;
l->insert(l->begin(), v);
} }
mdb_cursor_close(cursor); mdb_cursor_close(cursor);
@ -593,10 +599,13 @@ void LMDB::resolveRegularExpression(const std::string& var,
continue; continue;
} }
l->insert(l->begin(), new Variable( Variable *v = new Variable(
std::string(reinterpret_cast<char *>(key.mv_data), key.mv_size), new std::string(reinterpret_cast<char *>(key.mv_data),
std::string(reinterpret_cast<char *>(data.mv_data), key.mv_size),
data.mv_size))); new std::string(reinterpret_cast<char *>(data.mv_data),
data.mv_size));
v->m_dynamic_value = true;
l->insert(l->begin(), v);
} }
mdb_cursor_close(cursor); mdb_cursor_close(cursor);