Gcc 7 ParsedInternalKey replace memset with clear function.

Summary:
I haven't looked to see if a class variable inside a loop like this is always initialised.
Closes https://github.com/facebook/rocksdb/pull/2602

Differential Revision: D5475937

Pulled By: IslamAbdelRahman

fbshipit-source-id: 8570b308f9a4b49e2a56ccc9e9b84d7c46568c15
main
Daniel Black 8 years ago committed by Facebook Github Bot
parent a4c42e8007
commit 1d8aa2961c
  1. 6
      db/dbformat.h
  2. 2
      db/write_batch_test.cc
  3. 2
      java/rocksjni/write_batch_test.cc

@ -84,6 +84,12 @@ struct ParsedInternalKey {
ParsedInternalKey(const Slice& u, const SequenceNumber& seq, ValueType t)
: user_key(u), sequence(seq), type(t) { }
std::string DebugString(bool hex = false) const;
void clear() {
user_key.clear();
sequence = 0;
type = kTypeDeletion;
}
};
// Return the length of the encoding of "key".

@ -60,7 +60,7 @@ static std::string PrintContents(WriteBatch* b) {
}
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
ParsedInternalKey ikey;
memset((void*)&ikey, 0, sizeof(ikey));
ikey.clear();
EXPECT_TRUE(ParseInternalKey(iter->key(), &ikey));
switch (ikey.type) {
case kTypeValue:

@ -59,7 +59,7 @@ jbyteArray Java_org_rocksdb_WriteBatchTest_getContents(
rocksdb::ReadOptions(), &arena));
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
rocksdb::ParsedInternalKey ikey;
memset(reinterpret_cast<void*>(&ikey), 0, sizeof(ikey));
ikey.clear();
bool parsed = rocksdb::ParseInternalKey(iter->key(), &ikey);
if (!parsed) {
assert(parsed);

Loading…
Cancel
Save