Loading native/jni/src/defines.h +0 −7 Original line number Diff line number Diff line Loading @@ -293,13 +293,6 @@ static inline void prof_out(void) { #define M_PI_F 3.14159265f #define MAX_PERCENTILE 100 // Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator. // As such, this is the maximum number of characters will be needed to represent an int as a // string, including the terminator; this is used as the size of a string buffer large enough to // hold any value that is intended to fit in an integer, e.g. in the code that reads the header // of the binary dictionary where a {key,value} string pair scheme is used. #define LARGEST_INT_DIGIT_COUNT 11 #define NOT_A_CODE_POINT (-1) #define NOT_A_DISTANCE (-1) #define NOT_A_COORDINATE (-1) Loading native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,13 @@ namespace latinime { // Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator. // As such, this is the maximum number of characters will be needed to represent an int as a // string, including the terminator; this is used as the size of a string buffer large enough to // hold any value that is intended to fit in an integer, e.g. in the code that reads the header // of the binary dictionary where a {key,value} string pair scheme is used. const int HeaderReadWriteUtils::LARGEST_INT_DIGIT_COUNT = 11; const int HeaderReadWriteUtils::MAX_ATTRIBUTE_KEY_LENGTH = 256; const int HeaderReadWriteUtils::MAX_ATTRIBUTE_VALUE_LENGTH = 256; Loading Loading @@ -154,8 +161,8 @@ typedef DictionaryHeaderStructurePolicy::AttributeMap AttributeMap; /* static */ void HeaderReadWriteUtils::setIntAttributeInner(AttributeMap *const headerAttributes, const AttributeMap::key_type *const key, const int value) { AttributeMap::mapped_type valueVector; char charBuf[LARGEST_INT_DIGIT_COUNT + 1]; snprintf(charBuf, LARGEST_INT_DIGIT_COUNT + 1, "%d", value); char charBuf[LARGEST_INT_DIGIT_COUNT]; snprintf(charBuf, sizeof(charBuf), "%d", value); insertCharactersIntoVector(charBuf, &valueVector); (*headerAttributes)[*key] = valueVector; } Loading native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h +1 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ class HeaderReadWriteUtils { private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeaderReadWriteUtils); static const int LARGEST_INT_DIGIT_COUNT; static const int MAX_ATTRIBUTE_KEY_LENGTH; static const int MAX_ATTRIBUTE_VALUE_LENGTH; Loading Loading
native/jni/src/defines.h +0 −7 Original line number Diff line number Diff line Loading @@ -293,13 +293,6 @@ static inline void prof_out(void) { #define M_PI_F 3.14159265f #define MAX_PERCENTILE 100 // Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator. // As such, this is the maximum number of characters will be needed to represent an int as a // string, including the terminator; this is used as the size of a string buffer large enough to // hold any value that is intended to fit in an integer, e.g. in the code that reads the header // of the binary dictionary where a {key,value} string pair scheme is used. #define LARGEST_INT_DIGIT_COUNT 11 #define NOT_A_CODE_POINT (-1) #define NOT_A_DISTANCE (-1) #define NOT_A_COORDINATE (-1) Loading
native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,13 @@ namespace latinime { // Number of base-10 digits in the largest integer + 1 to leave room for a zero terminator. // As such, this is the maximum number of characters will be needed to represent an int as a // string, including the terminator; this is used as the size of a string buffer large enough to // hold any value that is intended to fit in an integer, e.g. in the code that reads the header // of the binary dictionary where a {key,value} string pair scheme is used. const int HeaderReadWriteUtils::LARGEST_INT_DIGIT_COUNT = 11; const int HeaderReadWriteUtils::MAX_ATTRIBUTE_KEY_LENGTH = 256; const int HeaderReadWriteUtils::MAX_ATTRIBUTE_VALUE_LENGTH = 256; Loading Loading @@ -154,8 +161,8 @@ typedef DictionaryHeaderStructurePolicy::AttributeMap AttributeMap; /* static */ void HeaderReadWriteUtils::setIntAttributeInner(AttributeMap *const headerAttributes, const AttributeMap::key_type *const key, const int value) { AttributeMap::mapped_type valueVector; char charBuf[LARGEST_INT_DIGIT_COUNT + 1]; snprintf(charBuf, LARGEST_INT_DIGIT_COUNT + 1, "%d", value); char charBuf[LARGEST_INT_DIGIT_COUNT]; snprintf(charBuf, sizeof(charBuf), "%d", value); insertCharactersIntoVector(charBuf, &valueVector); (*headerAttributes)[*key] = valueVector; } Loading
native/jni/src/suggest/policyimpl/dictionary/header/header_read_write_utils.h +1 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ class HeaderReadWriteUtils { private: DISALLOW_IMPLICIT_CONSTRUCTORS(HeaderReadWriteUtils); static const int LARGEST_INT_DIGIT_COUNT; static const int MAX_ATTRIBUTE_KEY_LENGTH; static const int MAX_ATTRIBUTE_VALUE_LENGTH; Loading