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) ParsedInternalKey(const Slice& u, const SequenceNumber& seq, ValueType t)
: user_key(u), sequence(seq), type(t) { } : user_key(u), sequence(seq), type(t) { }
std::string DebugString(bool hex = false) const; std::string DebugString(bool hex = false) const;
void clear() {
user_key.clear();
sequence = 0;
type = kTypeDeletion;
}
}; };
// Return the length of the encoding of "key". // 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()) { for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
ParsedInternalKey ikey; ParsedInternalKey ikey;
memset((void*)&ikey, 0, sizeof(ikey)); ikey.clear();
EXPECT_TRUE(ParseInternalKey(iter->key(), &ikey)); EXPECT_TRUE(ParseInternalKey(iter->key(), &ikey));
switch (ikey.type) { switch (ikey.type) {
case kTypeValue: case kTypeValue:

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

Loading…
Cancel
Save