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
This commit is contained in:
Daniel Black 2017-07-24 11:28:20 -07:00 committed by Facebook Github Bot
parent a4c42e8007
commit 1d8aa2961c
3 changed files with 8 additions and 2 deletions

View File

@ -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".

View File

@ -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:

View File

@ -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);