From a831884ee6afca4fb2cb70a13a773e10d32c6e40 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 1 Sep 2025 14:32:13 +0200 Subject: [PATCH] Free rocksdb iterators --- src/ifcparse/IfcFile.cpp | 4 ++-- src/ifcparse/IfcParse.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ifcparse/IfcFile.cpp b/src/ifcparse/IfcFile.cpp index 7ffcf82a28..7b365245cc 100644 --- a/src/ifcparse/IfcFile.cpp +++ b/src/ifcparse/IfcFile.cpp @@ -463,7 +463,7 @@ void IfcParse::impl::rocks_db_file_storage::process_deletion_inverse(IfcUtil::If { // compute next prefix that does not start with v|{id}| auto prefix = "v|" + std::to_string(id) + "|"; - auto it = db->NewIterator(rocksdb::ReadOptions()); + auto it = std::unique_ptr(db->NewIterator(rocksdb::ReadOptions())); it->Seek(prefix); while (it->Valid()) { it->Next(); @@ -493,7 +493,7 @@ void IfcParse::impl::rocks_db_file_storage::process_deletion_inverse(IfcUtil::If { auto prefix = "v|" + std::to_string(name) + "|"; - auto it = db->NewIterator(rocksdb::ReadOptions()); + auto it = std::unique_ptr(db->NewIterator(rocksdb::ReadOptions())); it->Seek(prefix); while (it->Valid() && it->key().starts_with(prefix)) { std::string s = it->value().ToString(); diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 8ba13111e3..567a349640 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -2324,7 +2324,7 @@ aggregate_of_instance::ptr IfcFile::instances_by_reference(int t) { else if constexpr (std::is_same_v, impl::rocks_db_file_storage>) { // @todo no lower/upper_bounds() implemented yet auto prefix = "v|" + std::to_string(t) + "|"; - auto it = x.db->NewIterator(rocksdb::ReadOptions()); + auto it = std::unique_ptr(x.db->NewIterator(rocksdb::ReadOptions())); it->Seek(prefix); while (it->Valid() && it->key().starts_with(prefix)) { std::vector vals(it->value().size() / sizeof(uint32_t)); @@ -2477,7 +2477,7 @@ std::vector IfcFile::get_inverse_indices(int instance_id) { } else if constexpr (std::is_same_v, impl::rocks_db_file_storage>) { // @todo no lower/upper_bounds() implemented yet auto prefix = "v|" + std::to_string(instance_id) + "|"; - auto it = x.db->NewIterator(rocksdb::ReadOptions()); + auto it = std::unique_ptr(x.db->NewIterator(rocksdb::ReadOptions())); it->Seek(prefix); while (it->Valid() && it->key().starts_with(prefix)) { std::vector vals(it->value().size() / sizeof(uint32_t)); @@ -2549,7 +2549,7 @@ aggregate_of_instance::ptr IfcFile::getInverse(int instance_id, const IfcParse:: if (attribute_index == -1) { // @todo no lower/upper_bounds() implemented yet auto prefix = "v|" + std::to_string(instance_id) + "|" + std::to_string(ent->index_in_schema()) + "|"; - auto it = x.db->NewIterator(rocksdb::ReadOptions()); + auto it = std::unique_ptr(x.db->NewIterator(rocksdb::ReadOptions())); it->Seek(prefix); while (it->Valid() && it->key().starts_with(prefix)) { std::vector vals(it->value().size() / sizeof(uint32_t));