Skip to content

Commit

Permalink
Fix: Reclaiming file descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Aug 4, 2023
1 parent 4d2127b commit 05e908f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/usearch/index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ class memory_mapped_file_t {

serialization_result_t open_if_not() noexcept {
serialization_result_t result;
if (!path_)
if (!path_ || ptr_)
return result;

#if defined(USEARCH_DEFINED_WINDOWS)
Expand Down Expand Up @@ -1338,7 +1338,7 @@ class memory_mapped_file_t {
}

// Map the entire file
byte_t* file = (byte_t*)mmap(NULL, file_stat.st_size, PROT_READ, MAP_PRIVATE, descriptor, 0);
byte_t* file = (byte_t*)mmap(NULL, file_stat.st_size, PROT_READ, MAP_SHARED, descriptor, 0);
if (file == MAP_FAILED) {
::close(descriptor);
return result.failed(std::strerror(errno));
Expand Down
2 changes: 1 addition & 1 deletion objc/USearchObjective.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ metric_kind_t to_native_metric(USearchMetric m) {

scalar_kind_t to_native_scalar(USearchScalar m) {
switch (m) {
case USearchScalarF8:
case USearchScalarI8:
return scalar_kind_t::i8_k;

case USearchScalarF16:
Expand Down

0 comments on commit 05e908f

Please sign in to comment.