diff options
| author | Yi Kong <yikong@google.com> | 2018-07-16 18:11:34 -0700 |
|---|---|---|
| committer | Yi Kong <yikong@google.com> | 2018-07-16 18:11:34 -0700 |
| commit | e1731a4f2e05f1abb4a45602067708851eaf1e14 (patch) | |
| tree | 339c0ce3d3de7d6f5e0fb9bdada9b6210d1d470f /libutils/include | |
| parent | 895acebe946e34d2626716c5c4d7d7f2cc28c39d (diff) | |
| download | system_core-e1731a4f2e05f1abb4a45602067708851eaf1e14.tar.gz system_core-e1731a4f2e05f1abb4a45602067708851eaf1e14.tar.bz2 system_core-e1731a4f2e05f1abb4a45602067708851eaf1e14.zip | |
[libutils] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.
Test: m
Bug: 68236239
Change-Id: I5e89ec8c42151875439d2656475a8739ab9cb7dc
Diffstat (limited to 'libutils/include')
| -rw-r--r-- | libutils/include/utils/Condition.h | 2 | ||||
| -rw-r--r-- | libutils/include/utils/LruCache.h | 26 | ||||
| -rw-r--r-- | libutils/include/utils/Printer.h | 6 | ||||
| -rw-r--r-- | libutils/include/utils/ProcessCallStack.h | 6 | ||||
| -rw-r--r-- | libutils/include/utils/RefBase.h | 2 |
5 files changed, 21 insertions, 21 deletions
diff --git a/libutils/include/utils/Condition.h b/libutils/include/utils/Condition.h index c8da67c27..540ed8292 100644 --- a/libutils/include/utils/Condition.h +++ b/libutils/include/utils/Condition.h @@ -124,7 +124,7 @@ inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) { #else // __APPLE__ // Apple doesn't support POSIX clocks. struct timeval t; - gettimeofday(&t, NULL); + gettimeofday(&t, nullptr); ts.tv_sec = t.tv_sec; ts.tv_nsec = t.tv_usec*1000; #endif diff --git a/libutils/include/utils/LruCache.h b/libutils/include/utils/LruCache.h index 89dccd613..36775d0f2 100644 --- a/libutils/include/utils/LruCache.h +++ b/libutils/include/utils/LruCache.h @@ -71,7 +71,7 @@ private: Entry* parent; Entry* child; - Entry(TKey _key, TValue _value) : key(_key), value(_value), parent(NULL), child(NULL) { + Entry(TKey _key, TValue _value) : key(_key), value(_value), parent(nullptr), child(nullptr) { } const TKey& getKey() const final { return key; } }; @@ -162,9 +162,9 @@ public: template <typename TKey, typename TValue> LruCache<TKey, TValue>::LruCache(uint32_t maxCapacity) : mSet(new LruCacheSet()) - , mListener(NULL) - , mOldest(NULL) - , mYoungest(NULL) + , mListener(nullptr) + , mOldest(nullptr) + , mYoungest(nullptr) , mMaxCapacity(maxCapacity) , mNullValue(0) { mSet->max_load_factor(1.0); @@ -236,7 +236,7 @@ bool LruCache<TKey, TValue>::remove(const TKey& key) { template <typename TKey, typename TValue> bool LruCache<TKey, TValue>::removeOldest() { - if (mOldest != NULL) { + if (mOldest != nullptr) { return remove(mOldest->key); // TODO: should probably abort if false } @@ -254,12 +254,12 @@ const TValue& LruCache<TKey, TValue>::peekOldestValue() { template <typename TKey, typename TValue> void LruCache<TKey, TValue>::clear() { if (mListener) { - for (Entry* p = mOldest; p != NULL; p = p->child) { + for (Entry* p = mOldest; p != nullptr; p = p->child) { (*mListener)(p->key, p->value); } } - mYoungest = NULL; - mOldest = NULL; + mYoungest = nullptr; + mOldest = nullptr; for (auto entry : *mSet.get()) { delete entry; } @@ -268,7 +268,7 @@ void LruCache<TKey, TValue>::clear() { template <typename TKey, typename TValue> void LruCache<TKey, TValue>::attachToCache(Entry& entry) { - if (mYoungest == NULL) { + if (mYoungest == nullptr) { mYoungest = mOldest = &entry; } else { entry.parent = mYoungest; @@ -279,19 +279,19 @@ void LruCache<TKey, TValue>::attachToCache(Entry& entry) { template <typename TKey, typename TValue> void LruCache<TKey, TValue>::detachFromCache(Entry& entry) { - if (entry.parent != NULL) { + if (entry.parent != nullptr) { entry.parent->child = entry.child; } else { mOldest = entry.child; } - if (entry.child != NULL) { + if (entry.child != nullptr) { entry.child->parent = entry.parent; } else { mYoungest = entry.parent; } - entry.parent = NULL; - entry.child = NULL; + entry.parent = nullptr; + entry.child = nullptr; } } diff --git a/libutils/include/utils/Printer.h b/libutils/include/utils/Printer.h index a6f69280e..7465927c8 100644 --- a/libutils/include/utils/Printer.h +++ b/libutils/include/utils/Printer.h @@ -45,7 +45,7 @@ public: // (Note that the default ALOG behavior is to ignore blank lines) LogPrinter(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0, + const char* prefix = nullptr, bool ignoreBlankLines = false); // Print the specified line to logcat. No \n at the end is necessary. @@ -66,7 +66,7 @@ public: // Create a printer using the specified file descriptor. // - Each line will be prefixed with 'indent' number of blank spaces. // - In addition, each line will be prefixed with the 'prefix' string. - FdPrinter(int fd, unsigned int indent = 0, const char* prefix = 0); + FdPrinter(int fd, unsigned int indent = 0, const char* prefix = nullptr); // Print the specified line to the file descriptor. \n is appended automatically. virtual void printLine(const char* string); @@ -90,7 +90,7 @@ public: // Create a printer using the specified String8 as the target. // - In addition, each line will be prefixed with the 'prefix' string. // - target's memory lifetime must be a superset of this String8Printer. - String8Printer(String8* target, const char* prefix = 0); + String8Printer(String8* target, const char* prefix = nullptr); // Append the specified line to the String8. \n is appended automatically. virtual void printLine(const char* string); diff --git a/libutils/include/utils/ProcessCallStack.h b/libutils/include/utils/ProcessCallStack.h index b5f2edc4c..7e0608677 100644 --- a/libutils/include/utils/ProcessCallStack.h +++ b/libutils/include/utils/ProcessCallStack.h @@ -43,13 +43,13 @@ public: // Print all stack traces to the log using the supplied logtag. void log(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0) const; + const char* prefix = nullptr) const; // Dump all stack traces to the specified file descriptor. - void dump(int fd, int indent = 0, const char* prefix = 0) const; + void dump(int fd, int indent = 0, const char* prefix = nullptr) const; // Return a string (possibly very long) containing all the stack traces. - String8 toString(const char* prefix = 0) const; + String8 toString(const char* prefix = nullptr) const; // Dump a serialized representation of all the stack traces to the specified printer. void print(Printer& printer) const; diff --git a/libutils/include/utils/RefBase.h b/libutils/include/utils/RefBase.h index 13b6a2bc9..1780cf22f 100644 --- a/libutils/include/utils/RefBase.h +++ b/libutils/include/utils/RefBase.h @@ -563,7 +563,7 @@ template<typename T> template<typename U> wp<T>& wp<T>::operator = (const sp<U>& other) { weakref_type* newRefs = - other != NULL ? other->createWeak(this) : 0; + other != nullptr ? other->createWeak(this) : 0; U* otherPtr(other.m_ptr); if (m_ptr) m_refs->decWeak(this); m_ptr = otherPtr; |
