[libutils] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I5e89ec8c42151875439d2656475a8739ab9cb7dc
diff --git a/libutils/VectorImpl.cpp b/libutils/VectorImpl.cpp
index ef3277f..00a904d 100644
--- a/libutils/VectorImpl.cpp
+++ b/libutils/VectorImpl.cpp
@@ -44,7 +44,7 @@
// ----------------------------------------------------------------------------
VectorImpl::VectorImpl(size_t itemSize, uint32_t flags)
- : mStorage(0), mCount(0), mFlags(flags), mItemSize(itemSize)
+ : mStorage(nullptr), mCount(0), mFlags(flags), mItemSize(itemSize)
{
}
@@ -77,7 +77,7 @@
mCount = rhs.mCount;
SharedBuffer::bufferFromData(mStorage)->acquire();
} else {
- mStorage = 0;
+ mStorage = nullptr;
mCount = 0;
}
}
@@ -89,14 +89,14 @@
if (mStorage) {
const SharedBuffer* sb = SharedBuffer::bufferFromData(mStorage);
SharedBuffer* editable = sb->attemptEdit();
- if (editable == 0) {
+ if (editable == nullptr) {
// If we're here, we're not the only owner of the buffer.
// We must make a copy of it.
editable = SharedBuffer::alloc(sb->size());
// Fail instead of returning a pointer to storage that's not
// editable. Otherwise we'd be editing the contents of a buffer
// for which we're not the only owner, which is undefined behaviour.
- LOG_ALWAYS_FATAL_IF(editable == NULL);
+ LOG_ALWAYS_FATAL_IF(editable == nullptr);
_do_copy(editable->data(), mStorage, mCount);
release_storage();
mStorage = editable->data();
@@ -141,7 +141,7 @@
ssize_t VectorImpl::insertAt(size_t index, size_t numItems)
{
- return insertAt(0, index, numItems);
+ return insertAt(nullptr, index, numItems);
}
ssize_t VectorImpl::insertAt(const void* item, size_t index, size_t numItems)
@@ -177,7 +177,7 @@
const ssize_t count = size();
if (count > 1) {
void* array = const_cast<void*>(arrayImpl());
- void* temp = 0;
+ void* temp = nullptr;
ssize_t i = 1;
while (i < count) {
void* item = reinterpret_cast<char*>(array) + mItemSize*(i);
@@ -205,7 +205,7 @@
_do_copy(next, curr, 1);
next = curr;
--j;
- curr = NULL;
+ curr = nullptr;
if (j >= 0) {
curr = reinterpret_cast<char*>(array) + mItemSize*(j);
}
@@ -233,7 +233,7 @@
void VectorImpl::push()
{
- push(0);
+ push(nullptr);
}
void VectorImpl::push(const void* item)
@@ -243,7 +243,7 @@
ssize_t VectorImpl::add()
{
- return add(0);
+ return add(nullptr);
}
ssize_t VectorImpl::add(const void* item)
@@ -253,7 +253,7 @@
ssize_t VectorImpl::replaceAt(size_t index)
{
- return replaceAt(0, index);
+ return replaceAt(nullptr, index);
}
ssize_t VectorImpl::replaceAt(const void* prototype, size_t index)
@@ -267,10 +267,10 @@
void* item = editItemLocation(index);
if (item != prototype) {
- if (item == 0)
+ if (item == nullptr)
return NO_MEMORY;
_do_destroy(item, 1);
- if (prototype == 0) {
+ if (prototype == nullptr) {
_do_construct(item, 1);
} else {
_do_copy(item, prototype, 1);
@@ -294,7 +294,7 @@
void VectorImpl::finish_vector()
{
release_storage();
- mStorage = 0;
+ mStorage = nullptr;
mCount = 0;
}
@@ -315,7 +315,7 @@
return reinterpret_cast<char*>(buffer) + index*mItemSize;
}
}
- return 0;
+ return nullptr;
}
const void* VectorImpl::itemLocation(size_t index) const
@@ -330,7 +330,7 @@
return reinterpret_cast<const char*>(buffer) + index*mItemSize;
}
}
- return 0;
+ return nullptr;
}
ssize_t VectorImpl::setCapacity(size_t new_capacity)
@@ -418,7 +418,7 @@
if (sb) {
mStorage = sb->data();
} else {
- return NULL;
+ return nullptr;
}
} else {
SharedBuffer* sb = SharedBuffer::alloc(new_alloc_size);
@@ -435,7 +435,7 @@
release_storage();
mStorage = const_cast<void*>(array);
} else {
- return NULL;
+ return nullptr;
}
}
} else {