Skip to content

Commit

Permalink
Centralize funny nullptr handling.
Browse files Browse the repository at this point in the history
Change-Id: I4b0ec5cf1311666c7de04d4e619189d9a66b8382
  • Loading branch information
spt29 committed Sep 11, 2020
1 parent 804c96d commit 9278cd4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions livestatus/src/Column.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,24 @@ const void *Column::shiftPointer(Row row) const {
ColumnOffsets ColumnOffsets::addIndirectOffset(int offset) const {
ColumnOffsets result{*this};
result.shifters_.emplace_back([offset](const void *p) {
// TODO(sp) Figure out what is actually going on regarding nullptr...
return p == nullptr ? nullptr : *offset_cast<const void *>(p, offset);
return *offset_cast<const void *>(p, offset);
});
return result;
}

ColumnOffsets ColumnOffsets::addOffset(int offset) const {
ColumnOffsets result{*this};
result.shifters_.emplace_back([offset](const void *p) {
// TODO(sp) Figure out what is actually going on regarding nullptr...
return p == nullptr ? nullptr : offset_cast<const void>(p, offset);
});
result.shifters_.emplace_back(
[offset](const void *p) { return offset_cast<const void>(p, offset); });
return result;
}

const void *ColumnOffsets::shiftPointer(const void *data) const {
for (const auto &s : shifters_) {
// TODO(sp) Figure out what is actually going on regarding nullptr...
if (data == nullptr) {
break;
}
data = s(data);
}
return data;
Expand Down

0 comments on commit 9278cd4

Please sign in to comment.