Skip to content

Commit

Permalink
using nullptr instead of NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
petergjoel committed May 14, 2019
1 parent f049f77 commit c670389
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 59 deletions.
4 changes: 2 additions & 2 deletions src/binarywrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace ptrie
if(size == 0 || offset >= encodingsize)
{
_nbytes = 0;
_blob = NULL;
_blob = nullptr;
return;
}

Expand All @@ -96,7 +96,7 @@ namespace ptrie
_nbytes -= offset;
else {
_nbytes = 0;
_blob = NULL;
_blob = nullptr;
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/binarywrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace ptrie
* Empty constructor, no data is allocated
*/

binarywrapper_t() : _blob(NULL), _nbytes(0)
binarywrapper_t() : _blob(nullptr), _nbytes(0)
{
}

Expand Down Expand Up @@ -229,7 +229,7 @@ namespace ptrie

inline void zero() const
{
if(_nbytes > 0 && _blob != NULL)
if(_nbytes > 0 && _blob != nullptr)
{
memset(const_raw(), 0x0, _nbytes);
}
Expand All @@ -243,7 +243,7 @@ namespace ptrie
{
if(_nbytes > __BW_BSIZE__)
dealloc(_blob);
_blob = NULL;
_blob = nullptr;
_nbytes = 0;
}

Expand Down
40 changes: 20 additions & 20 deletions src/linked_bucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ class linked_bucket_t {
linked_bucket_t(size_t threads)
: _tnext(threads) {
for (size_t i = 0; i < threads; ++i) {
_tnext[i] = NULL;
_tnext[i] = nullptr;
}
_begin = new bucket_t;
_begin->_count = 0;
_begin->_offset = 0;
_begin->_nbucket = NULL;
_begin->_nbucket = nullptr;
_tnext[0] = _begin;

_index = new index_t;
_index->_next = NULL;
_index->_next = nullptr;

memset(&_begin->_data, 0, sizeof(T)*C);
memset(&_index->_index, 0, sizeof(bucket_t*)*C);
Expand All @@ -78,19 +78,19 @@ class linked_bucket_t {
delete _begin;
_begin = n;

} while (_begin != NULL);
} while (_begin != nullptr);

do {
index_t* n = _index->_next.load();
delete _index;
_index = n;

} while (_index != NULL);
} while (_index != nullptr);
}

inline T& operator[](size_t i) {
bucket_t* n = indexToBucket(i);
if(n != NULL)
if(n != nullptr)
{
return n->_data[i % C];
}
Expand All @@ -100,8 +100,8 @@ class linked_bucket_t {
while (b <= i) {
b += C;
n = n->_nbucket.load();
if(n == NULL) std::cerr << "FAILED FETCHING ID: " << i << std::endl;
assert(n != NULL);
if(n == nullptr) std::cerr << "FAILED FETCHING ID: " << i << std::endl;
assert(n != nullptr);
}

return n->_data[i % C];
Expand All @@ -110,7 +110,7 @@ class linked_bucket_t {
inline const T& operator[](size_t i) const {

bucket_t* n = indexToBucket(i);
if(n != NULL)
if(n != nullptr)
{
return n->_data[i % C];
}
Expand All @@ -121,7 +121,7 @@ class linked_bucket_t {
while (b <= i) {
b += C;
n = n->_nbucket.load();
assert(n != NULL);
assert(n != nullptr);
}

return n->_data[i % C];
Expand All @@ -130,33 +130,33 @@ class linked_bucket_t {
size_t size() {
bucket_t* n = _begin;
size_t cnt = 0;
while (n != NULL) {
while (n != nullptr) {
cnt += n->_count;
n = n->_nbucket.load();
}
return cnt;
}

inline size_t next(size_t thread) {
if (_tnext[thread] == NULL || _tnext[thread]->_count == C) {
if (_tnext[thread] == nullptr || _tnext[thread]->_count == C) {
bucket_t* next = new bucket_t;
next->_count = 0;
next->_nbucket = NULL;
next->_nbucket = nullptr;
next->_offset = 0;
memset(&next->_data, 0, sizeof(T)*C);

bucket_t* n = _tnext[thread];
if (n == NULL) {
if (n == nullptr) {
n = _begin;
}

next->_offset = n->_offset.load() + C; // beginning of next

bucket_t* tmp = NULL;
bucket_t* tmp = nullptr;

while (!n->_nbucket.compare_exchange_weak(tmp, next)) {
if (tmp != NULL) {
assert(tmp != NULL);
if (tmp != nullptr) {
assert(tmp != nullptr);
n = tmp;
next->_offset += C;
}
Expand All @@ -174,7 +174,7 @@ class linked_bucket_t {

inline void pop_back(size_t thread)
{
assert(_tnext[thread] != NULL && _tnext[thread]->_count > 0);
assert(_tnext[thread] != nullptr && _tnext[thread]->_count > 0);
--_tnext[thread]->_count;
}

Expand All @@ -187,7 +187,7 @@ class linked_bucket_t {
{
index_t* old = tmp;
tmp = old->_next;
if(tmp == NULL)
if(tmp == nullptr)
{
// extend index if needed
index_t* nindex = new index_t;
Expand Down Expand Up @@ -215,7 +215,7 @@ class linked_bucket_t {
while(id >= C*C)
{
tmp = tmp->_next;
if(tmp == NULL) return NULL;
if(tmp == nullptr) return nullptr;
id -= C*C;
}
return tmp->_index[id/C];
Expand Down
Loading

0 comments on commit c670389

Please sign in to comment.