diff options
author | costan <costan@google.com> | 2018-03-09 10:32:55 -0800 |
---|---|---|
committer | Victor Costan <pwnall@chromium.org> | 2018-03-09 10:38:04 -0800 |
commit | 623d014a54f8cf9b74ad6aaba9181ca1e65c43a1 (patch) | |
tree | 5f1a680c264df7917a6d700a89ea4533985c84fd /db/c.cc | |
parent | 8c8024ea33d8efc8c415597fb7fa1745002961d6 (diff) | |
download | leveldb-623d014a54f8cf9b74ad6aaba9181ca1e65c43a1.tar.gz |
Expose Env::GetTempDirectory() for use in C test.
This removes the use of the non-portable headers <sys/types.h> and <unistd.h> in c_test.c.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188503102
Diffstat (limited to 'db/c.cc')
-rw-r--r-- | db/c.cc | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -5,7 +5,6 @@ #include "leveldb/c.h" #include <stdlib.h> -#include <unistd.h> #include "leveldb/cache.h" #include "leveldb/comparator.h" #include "leveldb/db.h" @@ -584,6 +583,18 @@ void leveldb_env_destroy(leveldb_env_t* env) { delete env; } +char* leveldb_env_get_test_directory(leveldb_env_t* env) { + std::string result; + if (!env->rep->GetTestDirectory(&result).ok()) { + return NULL; + } + + char* buffer = static_cast<char*>(malloc(result.size() + 1)); + memcpy(buffer, result.data(), result.size()); + buffer[result.size()] = '\0'; + return buffer; +} + void leveldb_free(void* ptr) { free(ptr); } |