|
@ -4,6 +4,8 @@ |
|
|
|
|
|
|
|
|
#include "leveldb/c.h"
|
|
|
#include "leveldb/c.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
#include <cstdint>
|
|
|
#include <cstdlib>
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
@ -119,7 +121,7 @@ struct leveldb_filterpolicy_t : public FilterPolicy { |
|
|
size_t len; |
|
|
size_t len; |
|
|
char* filter = (*create_)(state_, &key_pointers[0], &key_sizes[0], n, &len); |
|
|
char* filter = (*create_)(state_, &key_pointers[0], &key_sizes[0], n, &len); |
|
|
dst->append(filter, len); |
|
|
dst->append(filter, len); |
|
|
free(filter); |
|
|
|
|
|
|
|
|
std::free(filter); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool KeyMayMatch(const Slice& key, const Slice& filter) const override { |
|
|
bool KeyMayMatch(const Slice& key, const Slice& filter) const override { |
|
@ -150,14 +152,15 @@ static bool SaveError(char** errptr, const Status& s) { |
|
|
*errptr = strdup(s.ToString().c_str()); |
|
|
*errptr = strdup(s.ToString().c_str()); |
|
|
} else { |
|
|
} else { |
|
|
// TODO(sanjay): Merge with existing error?
|
|
|
// TODO(sanjay): Merge with existing error?
|
|
|
free(*errptr); |
|
|
|
|
|
|
|
|
std::free(*errptr); |
|
|
*errptr = strdup(s.ToString().c_str()); |
|
|
*errptr = strdup(s.ToString().c_str()); |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static char* CopyString(const std::string& str) { |
|
|
static char* CopyString(const std::string& str) { |
|
|
char* result = reinterpret_cast<char*>(malloc(sizeof(char) * str.size())); |
|
|
|
|
|
|
|
|
char* result = |
|
|
|
|
|
reinterpret_cast<char*>(std::malloc(sizeof(char) * str.size())); |
|
|
std::memcpy(result, str.data(), sizeof(char) * str.size()); |
|
|
std::memcpy(result, str.data(), sizeof(char) * str.size()); |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
@ -547,13 +550,13 @@ char* leveldb_env_get_test_directory(leveldb_env_t* env) { |
|
|
return nullptr; |
|
|
return nullptr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
char* buffer = static_cast<char*>(malloc(result.size() + 1)); |
|
|
|
|
|
|
|
|
char* buffer = static_cast<char*>(std::malloc(result.size() + 1)); |
|
|
std::memcpy(buffer, result.data(), result.size()); |
|
|
std::memcpy(buffer, result.data(), result.size()); |
|
|
buffer[result.size()] = '\0'; |
|
|
buffer[result.size()] = '\0'; |
|
|
return buffer; |
|
|
return buffer; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void leveldb_free(void* ptr) { free(ptr); } |
|
|
|
|
|
|
|
|
void leveldb_free(void* ptr) { std::free(ptr); } |
|
|
|
|
|
|
|
|
int leveldb_major_version() { return kMajorVersion; } |
|
|
int leveldb_major_version() { return kMajorVersion; } |
|
|
|
|
|
|
|
|