diff --git a/spine-c/include/spine/extension.h b/spine-c/include/spine/extension.h index 660088fbb..193c22fda 100644 --- a/spine-c/include/spine/extension.h +++ b/spine-c/include/spine/extension.h @@ -15,15 +15,17 @@ function. - Subclasses do not provide a dispose function, instead the base class' dispose function should be used, which will delegate to - a dispose function. + a dispose function pointer. - - Classes not designed for inheritance cannot be extended. They may use an internal subclass to hide private data and don't + - Classes not designed for inheritance cannot be extended because they may use an internal subclass to hide private data and don't expose function pointers. - - The public API hides implementation details such init/deinit functions. An internal API is exposed in extension.h to allow + - The public API hides implementation details, such as init/deinit functions. An internal API is exposed by extension.h to allow classes to be extended. Internal functions begin with underscore (_). - - OOP in C tends to lose type safety. Macros are provided in extension.h to give context for why a cast is being done. + - OOP in C tends to lose type safety. Macros for casting are provided in extension.h to give context for why a cast is being done. + + - If SPINE_SHORT_NAMES is defined, the "sp" prefix for all class names is optional. */ #ifndef SPINE_EXTENSION_H_ diff --git a/spine-c/src/spine/Animation.c b/spine-c/src/spine/Animation.c index 58dfab822..4f65d7fcd 100644 --- a/spine-c/src/spine/Animation.c +++ b/spine-c/src/spine/Animation.c @@ -552,7 +552,7 @@ void _spEventTimeline_dispose (spTimeline* timeline) { _spTimeline_deinit(timeline); for (i = 0; i < self->framesLength; ++i) - FREE(self->events[i]); + spEvent_dispose(self->events[i]); FREE(self->events); FREE(self->frames); FREE(self); diff --git a/spine-c/src/spine/BoundingBoxAttachment.c b/spine-c/src/spine/BoundingBoxAttachment.c index 215ac056f..f0f47f593 100644 --- a/spine-c/src/spine/BoundingBoxAttachment.c +++ b/spine-c/src/spine/BoundingBoxAttachment.c @@ -34,9 +34,18 @@ #include #include +void _spBoundingBoxAttachment_dispose (spAttachment* attachment) { + spBoundingBoxAttachment* self = SUB_CAST(spBoundingBoxAttachment, attachment); + + _spAttachment_deinit(attachment); + + FREE(self->vertices); + FREE(self); +} + spBoundingBoxAttachment* spBoundingBoxAttachment_create (const char* name) { spBoundingBoxAttachment* self = NEW(spBoundingBoxAttachment); - _spAttachment_init(SUPER(self), name, ATTACHMENT_BOUNDING_BOX, _spAttachment_deinit); + _spAttachment_init(SUPER(self), name, ATTACHMENT_BOUNDING_BOX, _spBoundingBoxAttachment_dispose); return self; } diff --git a/spine-c/src/spine/RegionAttachment.c b/spine-c/src/spine/RegionAttachment.c index 04f27bf9f..d3b283f2f 100644 --- a/spine-c/src/spine/RegionAttachment.c +++ b/spine-c/src/spine/RegionAttachment.c @@ -34,11 +34,19 @@ #include #include +void _spRegionAttachment_dispose (spAttachment* attachment) { + spRegionAttachment* self = SUB_CAST(spRegionAttachment, attachment); + + _spAttachment_deinit(attachment); + + FREE(self); +} + spRegionAttachment* spRegionAttachment_create (const char* name) { spRegionAttachment* self = NEW(spRegionAttachment); self->scaleX = 1; self->scaleY = 1; - _spAttachment_init(SUPER(self), name, ATTACHMENT_REGION, _spAttachment_deinit); + _spAttachment_init(SUPER(self), name, ATTACHMENT_REGION, _spRegionAttachment_dispose); return self; }