Fix valgrind error in c_test
Summary:
External contribution caused some valgrind errors: 1a34aaaef0
This diff fixes them
Test Plan: ran valgrind
Reviewers: sdong, yhchiang, ljin
Reviewed By: ljin
Subscribers: leveldb
Differential Revision: https://reviews.facebook.net/D19485
This commit is contained in:
parent
8f6e9ab209
commit
8a03935f8c
13
db/c.cc
13
db/c.cc
@ -428,8 +428,8 @@ rocksdb_t* rocksdb_open_column_families(
|
|||||||
const rocksdb_options_t* db_options,
|
const rocksdb_options_t* db_options,
|
||||||
const char* name,
|
const char* name,
|
||||||
int num_column_families,
|
int num_column_families,
|
||||||
const char** column_family_names,
|
const char** column_family_names,
|
||||||
const rocksdb_options_t** column_family_options,
|
const rocksdb_options_t** column_family_options,
|
||||||
rocksdb_column_family_handle_t** column_family_handles,
|
rocksdb_column_family_handle_t** column_family_handles,
|
||||||
char** errptr) {
|
char** errptr) {
|
||||||
std::vector<ColumnFamilyDescriptor> column_families;
|
std::vector<ColumnFamilyDescriptor> column_families;
|
||||||
@ -461,7 +461,7 @@ rocksdb_t* rocksdb_open_for_read_only_column_families(
|
|||||||
const char* name,
|
const char* name,
|
||||||
int num_column_families,
|
int num_column_families,
|
||||||
const char** column_family_names,
|
const char** column_family_names,
|
||||||
const rocksdb_options_t** column_family_options,
|
const rocksdb_options_t** column_family_options,
|
||||||
rocksdb_column_family_handle_t** column_family_handles,
|
rocksdb_column_family_handle_t** column_family_handles,
|
||||||
unsigned char error_if_log_file_exist,
|
unsigned char error_if_log_file_exist,
|
||||||
char** errptr) {
|
char** errptr) {
|
||||||
@ -507,6 +507,13 @@ char** rocksdb_list_column_families(
|
|||||||
return column_families;
|
return column_families;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rocksdb_list_column_families_destroy(char** list, size_t len) {
|
||||||
|
for (size_t i = 0; i < len; ++i) {
|
||||||
|
free(output[i]);
|
||||||
|
}
|
||||||
|
free(output);
|
||||||
|
}
|
||||||
|
|
||||||
rocksdb_column_family_handle_t* rocksdb_create_column_family(
|
rocksdb_column_family_handle_t* rocksdb_create_column_family(
|
||||||
rocksdb_t* db,
|
rocksdb_t* db,
|
||||||
const rocksdb_options_t* column_family_options,
|
const rocksdb_options_t* column_family_options,
|
||||||
|
10
db/c_test.c
10
db/c_test.c
@ -580,9 +580,10 @@ int main(int argc, char** argv) {
|
|||||||
CheckEqual("default", column_fams[0], 7);
|
CheckEqual("default", column_fams[0], 7);
|
||||||
CheckEqual("cf1", column_fams[1], 3);
|
CheckEqual("cf1", column_fams[1], 3);
|
||||||
CheckCondition(cflen == 2);
|
CheckCondition(cflen == 2);
|
||||||
|
rocksdb_list_column_families_destroy(column_fams, cflen);
|
||||||
|
|
||||||
rocksdb_options_t* cf_options = rocksdb_options_create();
|
rocksdb_options_t* cf_options = rocksdb_options_create();
|
||||||
|
|
||||||
const char* cf_names[2] = {"default", "cf1"};
|
const char* cf_names[2] = {"default", "cf1"};
|
||||||
const rocksdb_options_t* cf_opts[2] = {cf_options, cf_options};
|
const rocksdb_options_t* cf_opts[2] = {cf_options, cf_options};
|
||||||
rocksdb_column_family_handle_t* handles[2];
|
rocksdb_column_family_handle_t* handles[2];
|
||||||
@ -631,14 +632,15 @@ int main(int argc, char** argv) {
|
|||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
rocksdb_column_family_handle_destroy(handles[i]);
|
rocksdb_column_family_handle_destroy(handles[i]);
|
||||||
}
|
}
|
||||||
|
rocksdb_close(db);
|
||||||
|
rocksdb_destroy_db(options, dbname, &err);
|
||||||
|
rocksdb_options_destroy(db_options);
|
||||||
|
rocksdb_options_destroy(cf_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
StartPhase("prefix");
|
StartPhase("prefix");
|
||||||
{
|
{
|
||||||
// Create new database
|
// Create new database
|
||||||
rocksdb_close(db);
|
|
||||||
rocksdb_destroy_db(options, dbname, &err);
|
|
||||||
|
|
||||||
rocksdb_filterpolicy_t* policy = rocksdb_filterpolicy_create_bloom(10);
|
rocksdb_filterpolicy_t* policy = rocksdb_filterpolicy_create_bloom(10);
|
||||||
rocksdb_options_set_filter_policy(options, policy);
|
rocksdb_options_set_filter_policy(options, policy);
|
||||||
rocksdb_options_set_prefix_extractor(options, rocksdb_slicetransform_create_fixed_prefix(3));
|
rocksdb_options_set_prefix_extractor(options, rocksdb_slicetransform_create_fixed_prefix(3));
|
||||||
|
@ -99,8 +99,8 @@ extern rocksdb_t* rocksdb_open_column_families(
|
|||||||
const rocksdb_options_t* options,
|
const rocksdb_options_t* options,
|
||||||
const char* name,
|
const char* name,
|
||||||
int num_column_families,
|
int num_column_families,
|
||||||
const char** column_family_names,
|
const char** column_family_names,
|
||||||
const rocksdb_options_t** column_family_options,
|
const rocksdb_options_t** column_family_options,
|
||||||
rocksdb_column_family_handle_t** column_family_handles,
|
rocksdb_column_family_handle_t** column_family_handles,
|
||||||
char** errptr);
|
char** errptr);
|
||||||
|
|
||||||
@ -108,8 +108,8 @@ extern rocksdb_t* rocksdb_open_for_read_only_column_families(
|
|||||||
const rocksdb_options_t* options,
|
const rocksdb_options_t* options,
|
||||||
const char* name,
|
const char* name,
|
||||||
int num_column_families,
|
int num_column_families,
|
||||||
const char** column_family_names,
|
const char** column_family_names,
|
||||||
const rocksdb_options_t** column_family_options,
|
const rocksdb_options_t** column_family_options,
|
||||||
rocksdb_column_family_handle_t** column_family_handles,
|
rocksdb_column_family_handle_t** column_family_handles,
|
||||||
unsigned char error_if_log_file_exist,
|
unsigned char error_if_log_file_exist,
|
||||||
char** errptr);
|
char** errptr);
|
||||||
@ -119,6 +119,7 @@ char** rocksdb_list_column_families(
|
|||||||
const char* name,
|
const char* name,
|
||||||
size_t* lencf,
|
size_t* lencf,
|
||||||
char** errptr);
|
char** errptr);
|
||||||
|
void rocksdb_list_column_families_destroy(char** list, size_t len);
|
||||||
|
|
||||||
extern rocksdb_column_family_handle_t* rocksdb_create_column_family(
|
extern rocksdb_column_family_handle_t* rocksdb_create_column_family(
|
||||||
rocksdb_t* db,
|
rocksdb_t* db,
|
||||||
|
Loading…
Reference in New Issue
Block a user