Merge "Use memmove for all place src and dest can be same."

main
Keisuke Kuroyanagi 2014-01-20 19:31:52 +00:00 committed by Android (Google) Code Review
commit c894071b2d
4 changed files with 9 additions and 9 deletions

View File

@ -118,7 +118,7 @@ namespace latinime {
actualLength0 = i + 1;
}
actualLength0 = min(actualLength0, MAX_WORD_LENGTH);
memcpy(dest, src0, actualLength0 * sizeof(dest[0]));
memmove(dest, src0, actualLength0 * sizeof(dest[0]));
if (!src1 || length1 == 0) {
return actualLength0;
}
@ -130,7 +130,7 @@ namespace latinime {
actualLength1 = i + 1;
}
actualLength1 = min(actualLength1, MAX_WORD_LENGTH - actualLength0);
memcpy(&dest[actualLength0], src1, actualLength1 * sizeof(dest[0]));
memmove(&dest[actualLength0], src1, actualLength1 * sizeof(dest[0]));
return actualLength0 + actualLength1;
}
} // namespace latinime

View File

@ -17,7 +17,7 @@
#ifndef LATINIME_DIC_NODE_STATE_OUTPUT_H
#define LATINIME_DIC_NODE_STATE_OUTPUT_H
#include <cstring> // for memcpy()
#include <cstring> // for memmove()
#include <stdint.h>
#include "defines.h"
@ -38,7 +38,7 @@ class DicNodeStateOutput {
}
void init(const DicNodeStateOutput *const stateOutput) {
memcpy(mCodePointsBuf, stateOutput->mCodePointsBuf,
memmove(mCodePointsBuf, stateOutput->mCodePointsBuf,
stateOutput->mOutputtedCodePointCount * sizeof(mCodePointsBuf[0]));
mOutputtedCodePointCount = stateOutput->mOutputtedCodePointCount;
if (mOutputtedCodePointCount < MAX_WORD_LENGTH) {
@ -51,7 +51,7 @@ class DicNodeStateOutput {
if (mergedNodeCodePoints) {
const int additionalCodePointCount = min(static_cast<int>(mergedNodeCodePointCount),
MAX_WORD_LENGTH - mOutputtedCodePointCount);
memcpy(&mCodePointsBuf[mOutputtedCodePointCount], mergedNodeCodePoints,
memmove(&mCodePointsBuf[mOutputtedCodePointCount], mergedNodeCodePoints,
additionalCodePointCount * sizeof(mCodePointsBuf[0]));
mOutputtedCodePointCount = static_cast<uint16_t>(
mOutputtedCodePointCount + mergedNodeCodePointCount);

View File

@ -17,7 +17,7 @@
#ifndef LATINIME_DIC_NODE_STATE_PREVWORD_H
#define LATINIME_DIC_NODE_STATE_PREVWORD_H
#include <cstring> // for memset()
#include <cstring> // for memset() and memmove()
#include <stdint.h>
#include "defines.h"
@ -62,7 +62,7 @@ class DicNodeStatePrevWord {
mPrevWordProbability = prevWord->mPrevWordProbability;
mPrevWordPtNodePos = prevWord->mPrevWordPtNodePos;
mSecondWordFirstInputIndex = prevWord->mSecondWordFirstInputIndex;
memcpy(mPrevWord, prevWord->mPrevWord, prevWord->mPrevWordLength * sizeof(mPrevWord[0]));
memmove(mPrevWord, prevWord->mPrevWord, prevWord->mPrevWordLength * sizeof(mPrevWord[0]));
}
void init(const int16_t prevWordCount, const int16_t prevWordProbability,

View File

@ -18,7 +18,7 @@
#include "suggest/core/layout/proximity_info_state.h"
#include <cstring> // for memset() and memcpy()
#include <cstring> // for memset() and memmove()
#include <sstream> // for debug prints
#include <vector>
@ -285,7 +285,7 @@ float ProximityInfoState::getDirection(const int index0, const int index1) const
}
float ProximityInfoState::getMostProbableString(int *const codePointBuf) const {
memcpy(codePointBuf, mMostProbableString, sizeof(mMostProbableString));
memmove(codePointBuf, mMostProbableString, sizeof(mMostProbableString));
return mMostProbableStringProbability;
}