| 762 | } |
| 763 | |
| 764 | fdb_status fdb_open_for_compactor(fdb_file_handle **ptr_fhandle, |
| 765 | const char *filename, |
| 766 | fdb_config *fconfig, |
| 767 | struct list *cmp_func_list) |
| 768 | { |
| 769 | #ifdef _MEMPOOL |
| 770 | mempool_init(); |
| 771 | #endif |
| 772 | |
| 773 | fdb_file_handle *fhandle; |
| 774 | fdb_kvs_handle *handle; |
| 775 | |
| 776 | fhandle = (fdb_file_handle*)calloc(1, sizeof(fdb_file_handle)); |
| 777 | if (!fhandle) { // LCOV_EXCL_START |
| 778 | return FDB_RESULT_ALLOC_FAIL; |
| 779 | } // LCOV_EXCL_STOP |
| 780 | |
| 781 | handle = (fdb_kvs_handle *) calloc(1, sizeof(fdb_kvs_handle)); |
| 782 | if (!handle) { // LCOV_EXCL_START |
| 783 | free(fhandle); |
| 784 | return FDB_RESULT_ALLOC_FAIL; |
| 785 | } // LCOV_EXCL_STOP |
| 786 | |
| 787 | atomic_init_uint8_t(&handle->handle_busy, 0); |
| 788 | handle->shandle = NULL; |
| 789 | |
| 790 | fdb_file_handle_init(fhandle, handle); |
| 791 | if (cmp_func_list && list_begin(cmp_func_list)) { |
| 792 | fdb_file_handle_clone_cmp_func_list(fhandle, cmp_func_list); |
| 793 | } |
| 794 | fdb_status fs = _fdb_open(handle, filename, FDB_VFILENAME, fconfig); |
| 795 | if (fs == FDB_RESULT_SUCCESS) { |
| 796 | *ptr_fhandle = fhandle; |
| 797 | } else { |
| 798 | *ptr_fhandle = NULL; |
| 799 | free(handle); |
| 800 | fdb_file_handle_free(fhandle); |
| 801 | } |
| 802 | return fs; |
| 803 | } |
| 804 | |
| 805 | LIBFDB_API |
| 806 | fdb_status fdb_snapshot_open(fdb_kvs_handle *handle_in, |
no test coverage detected