summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/leveldb/c.h8
-rw-r--r--include/leveldb/cache.h10
-rw-r--r--include/leveldb/db.h6
-rw-r--r--include/leveldb/env.h80
-rw-r--r--include/leveldb/options.h2
-rw-r--r--include/leveldb/slice.h7
-rw-r--r--include/leveldb/table.h2
-rw-r--r--include/leveldb/table_builder.h2
8 files changed, 69 insertions, 48 deletions
diff --git a/include/leveldb/c.h b/include/leveldb/c.h
index 02c79ba..62e1f64 100644
--- a/include/leveldb/c.h
+++ b/include/leveldb/c.h
@@ -40,16 +40,16 @@
#ifndef STORAGE_LEVELDB_INCLUDE_C_H_
#define STORAGE_LEVELDB_INCLUDE_C_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include "leveldb/export.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Exported types */
typedef struct leveldb_t leveldb_t;
diff --git a/include/leveldb/cache.h b/include/leveldb/cache.h
index 7d1a221..a94c683 100644
--- a/include/leveldb/cache.h
+++ b/include/leveldb/cache.h
@@ -18,7 +18,7 @@
#ifndef STORAGE_LEVELDB_INCLUDE_CACHE_H_
#define STORAGE_LEVELDB_INCLUDE_CACHE_H_
-#include <stdint.h>
+#include <cstdint>
#include "leveldb/export.h"
#include "leveldb/slice.h"
@@ -96,14 +96,6 @@ class LEVELDB_EXPORT Cache {
// Return an estimate of the combined charges of all elements stored in the
// cache.
virtual size_t TotalCharge() const = 0;
-
- private:
- void LRU_Remove(Handle* e);
- void LRU_Append(Handle* e);
- void Unref(Handle* e);
-
- struct Rep;
- Rep* rep_;
};
} // namespace leveldb
diff --git a/include/leveldb/db.h b/include/leveldb/db.h
index b73014a..a13d147 100644
--- a/include/leveldb/db.h
+++ b/include/leveldb/db.h
@@ -5,8 +5,8 @@
#ifndef STORAGE_LEVELDB_INCLUDE_DB_H_
#define STORAGE_LEVELDB_INCLUDE_DB_H_
-#include <stdint.h>
-#include <stdio.h>
+#include <cstdint>
+#include <cstdio>
#include "leveldb/export.h"
#include "leveldb/iterator.h"
@@ -16,7 +16,7 @@ namespace leveldb {
// Update CMakeLists.txt if you change these
static const int kMajorVersion = 1;
-static const int kMinorVersion = 22;
+static const int kMinorVersion = 23;
struct Options;
struct ReadOptions;
diff --git a/include/leveldb/env.h b/include/leveldb/env.h
index 112fe96..e00895a 100644
--- a/include/leveldb/env.h
+++ b/include/leveldb/env.h
@@ -13,30 +13,26 @@
#ifndef STORAGE_LEVELDB_INCLUDE_ENV_H_
#define STORAGE_LEVELDB_INCLUDE_ENV_H_
-#include <stdarg.h>
-#include <stdint.h>
-
+#include <cstdarg>
+#include <cstdint>
#include <string>
#include <vector>
#include "leveldb/export.h"
#include "leveldb/status.h"
+// This workaround can be removed when leveldb::Env::DeleteFile is removed.
#if defined(_WIN32)
-// The leveldb::Env class below contains a DeleteFile method.
-// At the same time, <windows.h>, a fairly popular header
-// file for Windows applications, defines a DeleteFile macro.
+// On Windows, the method name DeleteFile (below) introduces the risk of
+// triggering undefined behavior by exposing the compiler to different
+// declarations of the Env class in different translation units.
//
-// Without any intervention on our part, the result of this
-// unfortunate coincidence is that the name of the
-// leveldb::Env::DeleteFile method seen by the compiler depends on
-// whether <windows.h> was included before or after the LevelDB
-// headers.
+// This is because <windows.h>, a fairly popular header file for Windows
+// applications, defines a DeleteFile macro. So, files that include the Windows
+// header before this header will contain an altered Env declaration.
//
-// To avoid headaches, we undefined DeleteFile (if defined) and
-// redefine it at the bottom of this file. This way <windows.h>
-// can be included before this file (or not at all) and the
-// exported method will always be leveldb::Env::DeleteFile.
+// This workaround ensures that the compiler sees the same Env declaration,
+// independently of whether <windows.h> was included.
#if defined(DeleteFile)
#undef DeleteFile
#define LEVELDB_DELETEFILE_UNDEFINED
@@ -54,7 +50,7 @@ class WritableFile;
class LEVELDB_EXPORT Env {
public:
- Env() = default;
+ Env();
Env(const Env&) = delete;
Env& operator=(const Env&) = delete;
@@ -122,15 +118,48 @@ class LEVELDB_EXPORT Env {
// Original contents of *results are dropped.
virtual Status GetChildren(const std::string& dir,
std::vector<std::string>* result) = 0;
-
// Delete the named file.
- virtual Status DeleteFile(const std::string& fname) = 0;
+ //
+ // The default implementation calls DeleteFile, to support legacy Env
+ // implementations. Updated Env implementations must override RemoveFile and
+ // ignore the existence of DeleteFile. Updated code calling into the Env API
+ // must call RemoveFile instead of DeleteFile.
+ //
+ // A future release will remove DeleteDir and the default implementation of
+ // RemoveDir.
+ virtual Status RemoveFile(const std::string& fname);
+
+ // DEPRECATED: Modern Env implementations should override RemoveFile instead.
+ //
+ // The default implementation calls RemoveFile, to support legacy Env user
+ // code that calls this method on modern Env implementations. Modern Env user
+ // code should call RemoveFile.
+ //
+ // A future release will remove this method.
+ virtual Status DeleteFile(const std::string& fname);
// Create the specified directory.
virtual Status CreateDir(const std::string& dirname) = 0;
// Delete the specified directory.
- virtual Status DeleteDir(const std::string& dirname) = 0;
+ //
+ // The default implementation calls DeleteDir, to support legacy Env
+ // implementations. Updated Env implementations must override RemoveDir and
+ // ignore the existence of DeleteDir. Modern code calling into the Env API
+ // must call RemoveDir instead of DeleteDir.
+ //
+ // A future release will remove DeleteDir and the default implementation of
+ // RemoveDir.
+ virtual Status RemoveDir(const std::string& dirname);
+
+ // DEPRECATED: Modern Env implementations should override RemoveDir instead.
+ //
+ // The default implementation calls RemoveDir, to support legacy Env user
+ // code that calls this method on modern Env implementations. Modern Env user
+ // code should call RemoveDir.
+ //
+ // A future release will remove this method.
+ virtual Status DeleteDir(const std::string& dirname);
// Store the size of fname in *file_size.
virtual Status GetFileSize(const std::string& fname, uint64_t* file_size) = 0;
@@ -271,7 +300,7 @@ class LEVELDB_EXPORT Logger {
virtual ~Logger();
// Write an entry to the log file with the specified format.
- virtual void Logv(const char* format, va_list ap) = 0;
+ virtual void Logv(const char* format, std::va_list ap) = 0;
};
// Identifies a locked file.
@@ -333,14 +362,14 @@ class LEVELDB_EXPORT EnvWrapper : public Env {
std::vector<std::string>* r) override {
return target_->GetChildren(dir, r);
}
- Status DeleteFile(const std::string& f) override {
- return target_->DeleteFile(f);
+ Status RemoveFile(const std::string& f) override {
+ return target_->RemoveFile(f);
}
Status CreateDir(const std::string& d) override {
return target_->CreateDir(d);
}
- Status DeleteDir(const std::string& d) override {
- return target_->DeleteDir(d);
+ Status RemoveDir(const std::string& d) override {
+ return target_->RemoveDir(d);
}
Status GetFileSize(const std::string& f, uint64_t* s) override {
return target_->GetFileSize(f, s);
@@ -375,7 +404,8 @@ class LEVELDB_EXPORT EnvWrapper : public Env {
} // namespace leveldb
-// Redefine DeleteFile if necessary.
+// This workaround can be removed when leveldb::Env::DeleteFile is removed.
+// Redefine DeleteFile if it was undefined earlier.
#if defined(_WIN32) && defined(LEVELDB_DELETEFILE_UNDEFINED)
#if defined(UNICODE)
#define DeleteFile DeleteFileW
diff --git a/include/leveldb/options.h b/include/leveldb/options.h
index b748772..0f285bc 100644
--- a/include/leveldb/options.h
+++ b/include/leveldb/options.h
@@ -5,7 +5,7 @@
#ifndef STORAGE_LEVELDB_INCLUDE_OPTIONS_H_
#define STORAGE_LEVELDB_INCLUDE_OPTIONS_H_
-#include <stddef.h>
+#include <cstddef>
#include "leveldb/export.h"
diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h
index 2df417d..37cb821 100644
--- a/include/leveldb/slice.h
+++ b/include/leveldb/slice.h
@@ -15,10 +15,9 @@
#ifndef STORAGE_LEVELDB_INCLUDE_SLICE_H_
#define STORAGE_LEVELDB_INCLUDE_SLICE_H_
-#include <assert.h>
-#include <stddef.h>
-#include <string.h>
-
+#include <cassert>
+#include <cstddef>
+#include <cstring>
#include <string>
#include "leveldb/export.h"
diff --git a/include/leveldb/table.h b/include/leveldb/table.h
index 25c6013..a30e903 100644
--- a/include/leveldb/table.h
+++ b/include/leveldb/table.h
@@ -5,7 +5,7 @@
#ifndef STORAGE_LEVELDB_INCLUDE_TABLE_H_
#define STORAGE_LEVELDB_INCLUDE_TABLE_H_
-#include <stdint.h>
+#include <cstdint>
#include "leveldb/export.h"
#include "leveldb/iterator.h"
diff --git a/include/leveldb/table_builder.h b/include/leveldb/table_builder.h
index 7d8896b..85710c3 100644
--- a/include/leveldb/table_builder.h
+++ b/include/leveldb/table_builder.h
@@ -13,7 +13,7 @@
#ifndef STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_
#define STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_
-#include <stdint.h>
+#include <cstdint>
#include "leveldb/export.h"
#include "leveldb/options.h"