From b7a788bc1e73db1b03664b52411928f3432feceb Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Fri, 2 May 2014 10:21:16 +0200 Subject: [PATCH] Fixed memory errors. --- spine-c/src/spine/Animation.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spine-c/src/spine/Animation.c b/spine-c/src/spine/Animation.c index 34a711427..d3e254edf 100644 --- a/spine-c/src/spine/Animation.c +++ b/spine-c/src/spine/Animation.c @@ -667,7 +667,7 @@ void _spFFDTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, flo for (i = 0; i < self->frameVerticesCount; i++) slot->attachmentVertices[i] += (lastVertices[i] - slot->attachmentVertices[i]) * alpha; } else - memcpy(slot->attachmentVertices, lastVertices, self->frameVerticesCount); + memcpy(slot->attachmentVertices, lastVertices, self->frameVerticesCount * sizeof(float)); return; } @@ -693,8 +693,24 @@ void _spFFDTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, flo } } +void _spFFDTimeline_dispose (spTimeline* timeline) { + spFFDTimeline* self = SUB_CAST(spFFDTimeline, timeline); + int i; + + _spCurveTimeline_deinit(SUPER(self)); + + for (i = 0; i < self->framesCount; ++i) + FREE(self->frameVertices[i]); + FREE(self->frameVertices); + FREE(self->frames); + FREE(self); +} + spFFDTimeline* spFFDTimeline_create (int frameCount, int frameVerticesCount) { - spFFDTimeline* self = SUB_CAST(spFFDTimeline, _spBaseTimeline_create(frameCount, SP_TIMELINE_FFD, 1, _spFFDTimeline_apply)); + spFFDTimeline* self = NEW(spFFDTimeline); + _spCurveTimeline_init(SUPER(self), SP_TIMELINE_FFD, frameCount, _spFFDTimeline_dispose, _spFFDTimeline_apply); + CONST_CAST(int, self->framesCount) = frameCount; + CONST_CAST(float*, self->frames) = CALLOC(float, self->framesCount); CONST_CAST(float**, self->frameVertices) = CALLOC(float*, frameCount); CONST_CAST(int, self->frameVerticesCount) = frameVerticesCount; return self;