diff --git a/librocksdb-sys/api/c.cc b/librocksdb-sys/api/c.cc index 22d7508..221000d 100644 --- a/librocksdb-sys/api/c.cc +++ b/librocksdb-sys/api/c.cc @@ -3,12 +3,12 @@ #include #include "c.h" -// static char* CopyString(const std::string& str) { -// char* result = reinterpret_cast(malloc(sizeof(char) * str.size()+1)); -// memcpy(result, str.data(), sizeof(char) * str.size()); -// result[sizeof(char) * str.size()] = 0; -// return result; -// } +static char* CopyString2(const std::string& str) { + char* result = reinterpret_cast(malloc(sizeof(char) * str.size()+1)); + memcpy(result, str.data(), sizeof(char) * str.size()); + result[sizeof(char) * str.size()] = 0; + return result; +} static bool SaveStatus(rocksdb_status_t* target, const Status source) { target->code = static_cast(source.code()); @@ -30,7 +30,7 @@ extern "C" { char* rocksdb_version() { auto name = ROCKSDB_NAMESPACE::GetRocksVersionAsString(true); - return CopyString(name); + return CopyString2(name); } rocksdb_pinnableslice_t* rocksdb_get_pinned_cf_with_status( diff --git a/librocksdb-sys/build.rs b/librocksdb-sys/build.rs index 14bb274..67e88a2 100644 --- a/librocksdb-sys/build.rs +++ b/librocksdb-sys/build.rs @@ -472,7 +472,7 @@ fn main() { bindgen_rocksdb(); if !try_to_find_and_link_lib("ROCKSDB") { - println!("cargo:rerun-if-changed=librocksdb-sys/rocksdb/"); + println!("cargo:rerun-if-changed=librocksdb-sys/"); fail_on_empty_directory("librocksdb-sys/rocksdb"); build_rocksdb(); } else {