summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorVictor Costan <costan@google.com>2019-05-28 10:17:03 -0700
committerVictor Costan <pwnall@chromium.org>2019-05-28 15:44:32 -0700
commit863f185970eff21e826e5fe1164a6215a515c23b (patch)
tree1c612a139d39b3a9ec2279cd08532b19828a140f /db
parenta3b71c1ff65e30ced00e85ebbca9ae5786af6626 (diff)
downloadleveldb-863f185970eff21e826e5fe1164a6215a515c23b.tar.gz
unsigned char -> uint8_t
PiperOrigin-RevId: 250309603
Diffstat (limited to 'db')
-rw-r--r--db/c.cc30
-rw-r--r--db/c_test.c8
-rw-r--r--db/dbformat.h8
3 files changed, 21 insertions, 25 deletions
diff --git a/db/c.cc b/db/c.cc
index 1f6fd64..3a492f9 100644
--- a/db/c.cc
+++ b/db/c.cc
@@ -4,7 +4,8 @@
#include "leveldb/c.h"
-#include <stdlib.h>
+#include <cstdint>
+#include <cstdlib>
#include "leveldb/cache.h"
#include "leveldb/comparator.h"
@@ -132,8 +133,8 @@ struct leveldb_filterpolicy_t : public FilterPolicy {
char* (*create_)(void*, const char* const* key_array,
const size_t* key_length_array, int num_keys,
size_t* filter_length);
- unsigned char (*key_match_)(void*, const char* key, size_t length,
- const char* filter, size_t filter_length);
+ uint8_t (*key_match_)(void*, const char* key, size_t length,
+ const char* filter, size_t filter_length);
};
struct leveldb_env_t {
@@ -281,7 +282,7 @@ void leveldb_iter_destroy(leveldb_iterator_t* iter) {
delete iter;
}
-unsigned char leveldb_iter_valid(const leveldb_iterator_t* iter) {
+uint8_t leveldb_iter_valid(const leveldb_iterator_t* iter) {
return iter->rep->Valid();
}
@@ -378,18 +379,15 @@ void leveldb_options_set_filter_policy(leveldb_options_t* opt,
opt->rep.filter_policy = policy;
}
-void leveldb_options_set_create_if_missing(leveldb_options_t* opt,
- unsigned char v) {
+void leveldb_options_set_create_if_missing(leveldb_options_t* opt, uint8_t v) {
opt->rep.create_if_missing = v;
}
-void leveldb_options_set_error_if_exists(leveldb_options_t* opt,
- unsigned char v) {
+void leveldb_options_set_error_if_exists(leveldb_options_t* opt, uint8_t v) {
opt->rep.error_if_exists = v;
}
-void leveldb_options_set_paranoid_checks(leveldb_options_t* opt,
- unsigned char v) {
+void leveldb_options_set_paranoid_checks(leveldb_options_t* opt, uint8_t v) {
opt->rep.paranoid_checks = v;
}
@@ -449,8 +447,8 @@ leveldb_filterpolicy_t* leveldb_filterpolicy_create(
char* (*create_filter)(void*, const char* const* key_array,
const size_t* key_length_array, int num_keys,
size_t* filter_length),
- unsigned char (*key_may_match)(void*, const char* key, size_t length,
- const char* filter, size_t filter_length),
+ uint8_t (*key_may_match)(void*, const char* key, size_t length,
+ const char* filter, size_t filter_length),
const char* (*name)(void*)) {
leveldb_filterpolicy_t* result = new leveldb_filterpolicy_t;
result->state_ = state;
@@ -497,12 +495,11 @@ leveldb_readoptions_t* leveldb_readoptions_create() {
void leveldb_readoptions_destroy(leveldb_readoptions_t* opt) { delete opt; }
void leveldb_readoptions_set_verify_checksums(leveldb_readoptions_t* opt,
- unsigned char v) {
+ uint8_t v) {
opt->rep.verify_checksums = v;
}
-void leveldb_readoptions_set_fill_cache(leveldb_readoptions_t* opt,
- unsigned char v) {
+void leveldb_readoptions_set_fill_cache(leveldb_readoptions_t* opt, uint8_t v) {
opt->rep.fill_cache = v;
}
@@ -517,8 +514,7 @@ leveldb_writeoptions_t* leveldb_writeoptions_create() {
void leveldb_writeoptions_destroy(leveldb_writeoptions_t* opt) { delete opt; }
-void leveldb_writeoptions_set_sync(leveldb_writeoptions_t* opt,
- unsigned char v) {
+void leveldb_writeoptions_set_sync(leveldb_writeoptions_t* opt, uint8_t v) {
opt->rep.sync = v;
}
diff --git a/db/c_test.c b/db/c_test.c
index ae14b99..16c77ee 100644
--- a/db/c_test.c
+++ b/db/c_test.c
@@ -120,7 +120,7 @@ static const char* CmpName(void* arg) {
}
// Custom filter policy
-static unsigned char fake_filter_result = 1;
+static uint8_t fake_filter_result = 1;
static void FilterDestroy(void* arg) { }
static const char* FilterName(void* arg) {
return "TestFilter";
@@ -135,10 +135,8 @@ static char* FilterCreate(
memcpy(result, "fake", 4);
return result;
}
-unsigned char FilterKeyMatch(
- void* arg,
- const char* key, size_t length,
- const char* filter, size_t filter_length) {
+uint8_t FilterKeyMatch(void* arg, const char* key, size_t length,
+ const char* filter, size_t filter_length) {
CheckCondition(filter_length == 4);
CheckCondition(memcmp(filter, "fake", 4) == 0);
return fake_filter_result;
diff --git a/db/dbformat.h b/db/dbformat.h
index abcb489..a1c30ed 100644
--- a/db/dbformat.h
+++ b/db/dbformat.h
@@ -5,7 +5,9 @@
#ifndef STORAGE_LEVELDB_DB_DBFORMAT_H_
#define STORAGE_LEVELDB_DB_DBFORMAT_H_
-#include <stdio.h>
+#include <cstddef>
+#include <cstdint>
+#include <string>
#include "leveldb/comparator.h"
#include "leveldb/db.h"
@@ -171,11 +173,11 @@ inline bool ParseInternalKey(const Slice& internal_key,
const size_t n = internal_key.size();
if (n < 8) return false;
uint64_t num = DecodeFixed64(internal_key.data() + n - 8);
- unsigned char c = num & 0xff;
+ uint8_t c = num & 0xff;
result->sequence = num >> 8;
result->type = static_cast<ValueType>(c);
result->user_key = Slice(internal_key.data(), n - 8);
- return (c <= static_cast<unsigned char>(kTypeValue));
+ return (c <= static_cast<uint8_t>(kTypeValue));
}
// A helper class useful for DBImpl::Get()