From ca0372c4157cb0b121b3aacac47445185173a8a0 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 15 Apr 2016 08:34:15 +0800 Subject: [PATCH] Fix insert operation. Handle case where move is unnecessary. --- spine-c/src/spine/Skeleton.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spine-c/src/spine/Skeleton.c b/spine-c/src/spine/Skeleton.c index 162988e47..77e396807 100644 --- a/spine-c/src/spine/Skeleton.c +++ b/spine-c/src/spine/Skeleton.c @@ -169,8 +169,10 @@ void spSkeleton_updateCache (const spSkeleton* self) { if (updatable == transformConstraint->bone || updatable == transformConstraint->target) { int insertIndex = ii + 1; int moveCount = (capacity-2) - insertIndex; - memmove(internal->updateCache + (insertIndex+1), internal->updateCache + insertIndex, moveCount * sizeof(void*)); - memmove(internal->updateCacheType + (insertIndex+1), internal->updateCacheType + insertIndex, moveCount * sizeof(_spUpdateType)); + if (moveCount > 0) { + memmove(internal->updateCache + (insertIndex + 1), internal->updateCache + insertIndex, moveCount * sizeof(void*)); + memmove(internal->updateCacheType + (insertIndex + 1), internal->updateCacheType + insertIndex, moveCount * sizeof(_spUpdateType)); + } internal->updateCacheCount++; internal->updateCache[insertIndex] = transformConstraint; internal->updateCacheType[insertIndex] = SP_UPDATE_TRANSFORM_CONSTRAINT;