mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Fixed memory leaks.
This commit is contained in:
parent
63f20379db
commit
a040063eb7
@ -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_
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -34,9 +34,18 @@
|
||||
#include <spine/BoundingBoxAttachment.h>
|
||||
#include <spine/extension.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -34,11 +34,19 @@
|
||||
#include <spine/RegionAttachment.h>
|
||||
#include <spine/extension.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user