From 13c0170d26f70ea252fda9c06b61ea9728f771f8 Mon Sep 17 00:00:00 2001 From: fedor Date: Wed, 24 Apr 2002 03:32:50 +0000 Subject: [PATCH] Free closure via NSData git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13533 72102866-910b-0410-8b05-ffd578937521 --- Source/GSFFIInvocation.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/GSFFIInvocation.m b/Source/GSFFIInvocation.m index 23253f174..a8e2ba5c8 100644 --- a/Source/GSFFIInvocation.m +++ b/Source/GSFFIInvocation.m @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -146,6 +147,7 @@ static IMP gs_objc_msg_forward (SEL sel) const char *sel_type; cifframe_t *cframe; ffi_closure *cclosure; + NSMutableData *amemory; NSMethodSignature *sig; @@ -169,8 +171,9 @@ static IMP gs_objc_msg_forward (SEL sel) where it becomes owned by the callback invocation, so we don't have to worry about freeing it */ cframe = cifframe_from_info([sig methodInfo], [sig numberOfArguments], NULL); - /* FIXME: But how to we free this? */ - cclosure = NSZoneCalloc(NSDefaultMallocZone(), sizeof(ffi_closure), 1); + /* Free the closure through NSData */ + amemory = [NSMutableData dataWithLength: sizeof(ffi_closure)]; + cclosure = [amemory mutableBytes]; if (cframe == NULL || cclosure == NULL) { [NSException raise: NSMallocException format: @"Allocating closure"];