Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Address valgrind warnings.

Kishore Nallanad72f36dd68d
diff --git a/docker/debugger.Dockerfile b/docker/debugger.Dockerfile
index b0687d15..ac216bfc 100644
--- a/docker/debugger.Dockerfile
+++ b/docker/debugger.Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:16.04
+FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install -y gdb valgrind
\ No newline at end of file
diff --git a/include/array_base.h b/include/array_base.h
index 53ef54df..450e0a0e 100644
--- a/include/array_base.h
+++ b/include/array_base.h
@@ -27,12 +27,12 @@ protected:
public:
array_base(const uint32_t n=2) {
size_bytes = METADATA_OVERHEAD + (n * FOR_ELE_SIZE);
- in = new uint8_t[size_bytes];
+ in = (uint8_t *) malloc(size_bytes * sizeof *in);
memset(in, 0, size_bytes);
}
~array_base() {
- delete[] in;
+ free(in);
in = nullptr;
}
diff --git a/include/string_utils.h b/include/string_utils.h
index cd022add..a4d33c0c 100644
--- a/include/string_utils.h
+++ b/include/string_utils.h
@@ -20,6 +20,7 @@ struct StringUtils {
~StringUtils() {
//delete transliterator;
+ iconv_close(cd);
}
// Adapted from: http://stackoverflow.com/a/236180/131050
diff --git a/src/collection_manager.cpp b/src/collection_manager.cpp
index d9a594a5..e937d292 100644
--- a/src/collection_manager.cpp
+++ b/src/collection_manager.cpp
@@ -132,6 +132,8 @@ Option<bool> CollectionManager::init(Store *store, const std::string & auth_key,
iter->Next();
}
+ delete iter;
+
return Option<bool>(true);
}
diff --git a/src/sorted_array.cpp b/src/sorted_array.cpp
index cffc553f..bd7d916c 100644
--- a/src/sorted_array.cpp
+++ b/src/sorted_array.cpp
@@ -9,7 +9,7 @@ void sorted_array::load(const uint32_t *sorted_array, const uint32_t array_lengt
uint8_t *out = new uint8_t[size_required];
uint32_t actual_size = for_compress_sorted(sorted_array, out, array_length);
- delete[] in;
+ free(in);
in = nullptr;
in = out;