Skip to content

Commit

Permalink
MB-62221: API to free a buffer allocated in C runtime (#30)
Browse files Browse the repository at this point in the history
- Adds an API to free the communication buffer used to bridge Faiss and go-faiss.
  • Loading branch information
CascadingRadium authored Jun 13, 2024
1 parent a2f4183 commit d9db66a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions c_api/index_io_c_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,8 @@ int faiss_read_index_buf(const uint8_t* buf, size_t size, int io_flags, FaissInd
}
CATCH_AND_HANDLE
}

void faiss_free_buf(uint8_t** buf) {
free(*buf);
*buf = nullptr;
}
2 changes: 2 additions & 0 deletions c_api/index_io_c_ex.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ int faiss_write_index_buf(const FaissIndex* idx, size_t* buf_size, uint8_t** buf
int faiss_read_index_buf(const uint8_t* buf, size_t limit, int io_flags,
FaissIndex** p_out);

void faiss_free_buf(uint8_t** buf);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit d9db66a

Please sign in to comment.