diff --git a/c_api/index_io_c_ex.cpp b/c_api/index_io_c_ex.cpp index adcbe77b32..0efe59eb95 100644 --- a/c_api/index_io_c_ex.cpp +++ b/c_api/index_io_c_ex.cpp @@ -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; +} diff --git a/c_api/index_io_c_ex.h b/c_api/index_io_c_ex.h index 31f0339477..b0217bdab8 100644 --- a/c_api/index_io_c_ex.h +++ b/c_api/index_io_c_ex.h @@ -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