From 6c7ebc4023086fd61dcc19688663616c4781672a Mon Sep 17 00:00:00 2001
From: Keisuke Kuroyanagi <ksk@google.com>
Date: Fri, 7 Mar 2014 10:04:44 +0900
Subject: [PATCH] Use nullptr instead of 0 for pointers.

Change-Id: Ic9425de07b896f940ca11c51968c637ebb897514
---
 ...com_android_inputmethod_latin_BinaryDictionary.cpp |  2 +-
 native/jni/src/suggest/core/dicnode/dic_node.cpp      |  2 +-
 native/jni/src/suggest/core/dicnode/dic_node.h        |  2 +-
 .../jni/src/suggest/core/dictionary/digraph_utils.cpp | 10 +++++-----
 .../src/suggest/core/layout/proximity_info_state.h    |  2 +-
 .../src/suggest/core/session/dic_traverse_session.h   |  4 ++--
 native/jni/src/suggest/core/suggest.h                 |  6 +++---
 .../structure/v4/content/single_dict_content.h        |  5 +++--
 .../structure/v4/content/sparse_table_dict_content.h  | 11 ++++++-----
 .../dictionary/structure/v4/ver4_dict_buffers.cpp     |  6 +++---
 .../policyimpl/dictionary/utils/mmapped_buffer.h      |  4 ++--
 11 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index 7a7816d5a..31a4849dc 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -161,7 +161,7 @@ static int latinime_BinaryDictionary_getSuggestions(JNIEnv *env, jclass clazz, j
     const jsize prevWordCodePointsLength =
             prevWordCodePointsForBigrams ? env->GetArrayLength(prevWordCodePointsForBigrams) : 0;
     int prevWordCodePointsInternal[prevWordCodePointsLength];
-    int *prevWordCodePoints = 0;
+    int *prevWordCodePoints = nullptr;
     env->GetIntArrayRegion(xCoordinatesArray, 0, inputSize, xCoordinates);
     env->GetIntArrayRegion(yCoordinatesArray, 0, inputSize, yCoordinates);
     env->GetIntArrayRegion(timesArray, 0, inputSize, times);
diff --git a/native/jni/src/suggest/core/dicnode/dic_node.cpp b/native/jni/src/suggest/core/dicnode/dic_node.cpp
index de088c7d0..73855977e 100644
--- a/native/jni/src/suggest/core/dicnode/dic_node.cpp
+++ b/native/jni/src/suggest/core/dicnode/dic_node.cpp
@@ -25,7 +25,7 @@ DicNode::DicNode(const DicNode &dicNode)
 #endif
           mDicNodeProperties(dicNode.mDicNodeProperties), mDicNodeState(dicNode.mDicNodeState),
           mIsCachedForNextSuggestion(dicNode.mIsCachedForNextSuggestion), mIsUsed(dicNode.mIsUsed),
-          mReleaseListener(0) {
+          mReleaseListener(nullptr) {
     /* empty */
 }
 
diff --git a/native/jni/src/suggest/core/dicnode/dic_node.h b/native/jni/src/suggest/core/dicnode/dic_node.h
index 558667eb0..b812f8ff4 100644
--- a/native/jni/src/suggest/core/dicnode/dic_node.h
+++ b/native/jni/src/suggest/core/dicnode/dic_node.h
@@ -93,7 +93,7 @@ class DicNode {
               mProfiler(),
 #endif
               mDicNodeProperties(), mDicNodeState(), mIsCachedForNextSuggestion(false),
-              mIsUsed(false), mReleaseListener(0) {}
+              mIsUsed(false), mReleaseListener(nullptr) {}
 
     DicNode(const DicNode &dicNode);
     DicNode &operator=(const DicNode &dicNode);
diff --git a/native/jni/src/suggest/core/dictionary/digraph_utils.cpp b/native/jni/src/suggest/core/dictionary/digraph_utils.cpp
index 5f9b8f3e2..bb2ce5012 100644
--- a/native/jni/src/suggest/core/dictionary/digraph_utils.cpp
+++ b/native/jni/src/suggest/core/dictionary/digraph_utils.cpp
@@ -84,7 +84,7 @@ const DigraphUtils::DigraphType DigraphUtils::USED_DIGRAPH_TYPES[] =
 }
 
 /**
- * Returns the digraph for the input composite glyph codepoint, or 0 if none exists.
+ * Returns the digraph for the input composite glyph codepoint, or nullptr if none exists.
  * compositeGlyphCodePoint: the method returns the digraph corresponding to this codepoint.
  */
 /* static */ const DigraphUtils::digraph_t *DigraphUtils::getDigraphForCodePoint(
@@ -96,17 +96,17 @@ const DigraphUtils::DigraphType DigraphUtils::USED_DIGRAPH_TYPES[] =
             return digraph;
         }
     }
-    return 0;
+    return nullptr;
 }
 
 /**
- * Returns the digraph for the input composite glyph codepoint, or 0 if none exists.
+ * Returns the digraph for the input composite glyph codepoint, or nullptr if none exists.
  * digraphType: the type of digraphs supported.
  * compositeGlyphCodePoint: the method returns the digraph corresponding to this codepoint.
  */
 /* static */ const DigraphUtils::digraph_t *DigraphUtils::getDigraphForDigraphTypeAndCodePoint(
         const DigraphUtils::DigraphType digraphType, const int compositeGlyphCodePoint) {
-    const DigraphUtils::digraph_t *digraphs = 0;
+    const DigraphUtils::digraph_t *digraphs = nullptr;
     const int compositeGlyphLowerCodePoint = CharUtils::toLowerCase(compositeGlyphCodePoint);
     const int digraphsSize =
             DigraphUtils::getAllDigraphsForDigraphTypeAndReturnSize(digraphType, &digraphs);
@@ -115,7 +115,7 @@ const DigraphUtils::DigraphType DigraphUtils::USED_DIGRAPH_TYPES[] =
             return &digraphs[i];
         }
     }
-    return 0;
+    return nullptr;
 }
 
 } // namespace latinime
diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.h b/native/jni/src/suggest/core/layout/proximity_info_state.h
index e941e43d8..9abd69a66 100644
--- a/native/jni/src/suggest/core/layout/proximity_info_state.h
+++ b/native/jni/src/suggest/core/layout/proximity_info_state.h
@@ -43,7 +43,7 @@ class ProximityInfoState {
     // Defined here                        //
     /////////////////////////////////////////
     AK_FORCE_INLINE ProximityInfoState()
-            : mProximityInfo(0), mMaxPointToKeyLength(0.0f), mAverageSpeed(0.0f),
+            : mProximityInfo(nullptr), mMaxPointToKeyLength(0.0f), mAverageSpeed(0.0f),
               mHasTouchPositionCorrectionData(false), mMostCommonKeyWidthSquare(0),
               mKeyCount(0), mCellHeight(0), mCellWidth(0), mGridHeight(0), mGridWidth(0),
               mIsContinuousSuggestionPossible(false), mHasBeenUpdatedByGeometricInput(false),
diff --git a/native/jni/src/suggest/core/session/dic_traverse_session.h b/native/jni/src/suggest/core/session/dic_traverse_session.h
index 6e4dda44d..b718fb57a 100644
--- a/native/jni/src/suggest/core/session/dic_traverse_session.h
+++ b/native/jni/src/suggest/core/session/dic_traverse_session.h
@@ -59,8 +59,8 @@ class DicTraverseSession {
     }
 
     AK_FORCE_INLINE DicTraverseSession(JNIEnv *env, jstring localeStr, bool usesLargeCache)
-            : mPrevWordPtNodePos(NOT_A_DICT_POS), mProximityInfo(0),
-              mDictionary(0), mSuggestOptions(0), mDicNodesCache(usesLargeCache),
+            : mPrevWordPtNodePos(NOT_A_DICT_POS), mProximityInfo(nullptr),
+              mDictionary(nullptr), mSuggestOptions(nullptr), mDicNodesCache(usesLargeCache),
               mMultiBigramMap(), mInputSize(0), mPartiallyCommited(false), mMaxPointerCount(1),
               mMultiWordCostMultiplier(1.0f) {
         // NOTE: mProximityInfoStates is an array of instances.
diff --git a/native/jni/src/suggest/core/suggest.h b/native/jni/src/suggest/core/suggest.h
index b1d12ad9a..c42986ad6 100644
--- a/native/jni/src/suggest/core/suggest.h
+++ b/native/jni/src/suggest/core/suggest.h
@@ -42,9 +42,9 @@ class Weighting;
 class Suggest : public SuggestInterface {
  public:
     AK_FORCE_INLINE Suggest(const SuggestPolicy *const suggestPolicy)
-            : TRAVERSAL(suggestPolicy ? suggestPolicy->getTraversal() : 0),
-              SCORING(suggestPolicy ? suggestPolicy->getScoring() : 0),
-              WEIGHTING(suggestPolicy ? suggestPolicy->getWeighting() : 0) {}
+            : TRAVERSAL(suggestPolicy ? suggestPolicy->getTraversal() : nullptr),
+              SCORING(suggestPolicy ? suggestPolicy->getScoring() : nullptr),
+              WEIGHTING(suggestPolicy ? suggestPolicy->getWeighting() : nullptr) {}
     AK_FORCE_INLINE virtual ~Suggest() {}
     int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
             int *times, int *pointerIds, int *inputCodePoints, int inputSize, int commitPoint,
diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/single_dict_content.h b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/single_dict_content.h
index 9064b7e72..edf65837e 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/single_dict_content.h
+++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/single_dict_content.h
@@ -31,10 +31,11 @@ class SingleDictContent : public DictContent {
     SingleDictContent(const char *const dictPath, const char *const contentFileName,
             const bool isUpdatable)
             : mMmappedBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)),
-              mExpandableContentBuffer(mMmappedBuffer.get() ? mMmappedBuffer.get()->getBuffer() : 0,
+              mExpandableContentBuffer(mMmappedBuffer.get() ?
+                              mMmappedBuffer.get()->getBuffer() : nullptr,
                       mMmappedBuffer.get() ? mMmappedBuffer.get()->getBufferSize() : 0,
                       BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
-              mIsValid(mMmappedBuffer.get() != 0) {}
+              mIsValid(mMmappedBuffer.get()) {}
 
     SingleDictContent()
             : mMmappedBuffer(0), mExpandableContentBuffer(Ver4DictConstants::MAX_DICTIONARY_SIZE),
diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/sparse_table_dict_content.h b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/sparse_table_dict_content.h
index a82e3f50a..2bb7f9a3c 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/sparse_table_dict_content.h
+++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/sparse_table_dict_content.h
@@ -40,20 +40,21 @@ class SparseTableDictContent : public DictContent {
                       MmappedBuffer::openBuffer(dictPath, addressTableFileName, isUpdatable)),
               mContentBuffer(MmappedBuffer::openBuffer(dictPath, contentFileName, isUpdatable)),
               mExpandableLookupTableBuffer(
-                      mLookupTableBuffer.get() ? mLookupTableBuffer.get()->getBuffer() : 0,
+                      mLookupTableBuffer.get() ? mLookupTableBuffer.get()->getBuffer() : nullptr,
                       mLookupTableBuffer.get() ? mLookupTableBuffer.get()->getBufferSize() : 0,
                       BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
               mExpandableAddressTableBuffer(
-                      mAddressTableBuffer.get() ? mAddressTableBuffer.get()->getBuffer() : 0,
+                      mAddressTableBuffer.get() ? mAddressTableBuffer.get()->getBuffer() : nullptr,
                       mAddressTableBuffer.get() ? mAddressTableBuffer.get()->getBufferSize() : 0,
                       BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
-              mExpandableContentBuffer(mContentBuffer.get() ? mContentBuffer.get()->getBuffer() : 0,
+              mExpandableContentBuffer(mContentBuffer.get() ?
+                              mContentBuffer.get()->getBuffer() : nullptr,
                       mContentBuffer.get() ? mContentBuffer.get()->getBufferSize() : 0,
                       BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
               mAddressLookupTable(&mExpandableLookupTableBuffer, &mExpandableAddressTableBuffer,
                       sparseTableBlockSize, sparseTableDataSize),
-              mIsValid(mLookupTableBuffer.get() != 0 && mAddressTableBuffer.get() != 0
-                      && mContentBuffer.get() != 0) {}
+              mIsValid(mLookupTableBuffer.get() && mAddressTableBuffer.get()
+                      && mContentBuffer.get()) {}
 
     SparseTableDictContent(const int sparseTableBlockSize, const int sparseTableDataSize)
             : mLookupTableBuffer(0), mAddressTableBuffer(0), mContentBuffer(0),
diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
index 59dedee72..5ee4b79a5 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
+++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/ver4_dict_buffers.cpp
@@ -31,7 +31,7 @@ namespace latinime {
     if (!headerBuffer.get()) {
         ASSERT(false);
         AKLOGE("The header buffer must be valid to open ver4 dict buffers.");
-        return Ver4DictBuffersPtr(0);
+        return Ver4DictBuffersPtr(nullptr);
     }
     // TODO: take only dictDirPath, and open both header and trie files in the constructor below
     return Ver4DictBuffersPtr(new Ver4DictBuffers(
@@ -118,10 +118,10 @@ Ver4DictBuffers::Ver4DictBuffers(const char *const dictPath,
           mDictBuffer(MmappedBuffer::openBuffer(dictPath,
                   Ver4DictConstants::TRIE_FILE_EXTENSION, isUpdatable)),
           mHeaderPolicy(headerBuffer.get()->getBuffer(), FormatUtils::VERSION_4),
-          mExpandableHeaderBuffer(headerBuffer.get() ? headerBuffer.get()->getBuffer() : 0,
+          mExpandableHeaderBuffer(headerBuffer.get() ? headerBuffer.get()->getBuffer() : nullptr,
                   mHeaderPolicy.getSize(),
                   BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
-          mExpandableTrieBuffer(mDictBuffer.get() ? mDictBuffer.get()->getBuffer() : 0,
+          mExpandableTrieBuffer(mDictBuffer.get() ? mDictBuffer.get()->getBuffer() : nullptr,
                   mDictBuffer.get() ? mDictBuffer.get()->getBufferSize() : 0,
                   BufferWithExtendableBuffer::DEFAULT_MAX_ADDITIONAL_BUFFER_SIZE),
           mTerminalPositionLookupTable(dictPath, isUpdatable),
diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.h b/native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.h
index 73a733b0c..27ec4b2b0 100644
--- a/native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.h
+++ b/native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.h
@@ -60,8 +60,8 @@ class MmappedBuffer {
 
     // Empty file. We have to handle an empty file as a valid part of a dictionary.
     AK_FORCE_INLINE MmappedBuffer(const bool isUpdatable)
-            : mBuffer(0), mBufferSize(0), mMmappedBuffer(0), mAlignedSize(0), mMmapFd(0),
-              mIsUpdatable(isUpdatable) {}
+            : mBuffer(nullptr), mBufferSize(0), mMmappedBuffer(nullptr), mAlignedSize(0),
+              mMmapFd(0), mIsUpdatable(isUpdatable) {}
 
     DISALLOW_IMPLICIT_CONSTRUCTORS(MmappedBuffer);