From b4c482f010c2d26ef2dc275186d3ea1d32d97c24 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 21 Dec 2015 17:50:44 -0800 Subject: [PATCH] Memory allocated by new will be garbage collected. --- Execute.cpp | 7 +++++-- modules/com/saurik/substrate/MS.cy | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Execute.cpp b/Execute.cpp index e575f94..0402829 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1491,8 +1491,11 @@ static JSObjectRef Type_callAsConstructor(JSContextRef context, JSObjectRef obje type = type->data.data.type; } - void *value(calloc(1, internal->GetFFI()->size)); - return CYMakePointer(context, value, length, type, NULL, NULL); + JSObjectRef pointer(CYMakePointer(context, NULL, length, type, NULL, NULL)); + Pointer *value(reinterpret_cast(JSObjectGetPrivate(pointer))); + value->value_ = value->pool_->malloc(internal->GetFFI()->size); + memset(value->value_, 0, internal->GetFFI()->size); + return pointer; } CYCatch(NULL) } static JSObjectRef Functor_new(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { diff --git a/modules/com/saurik/substrate/MS.cy b/modules/com/saurik/substrate/MS.cy index 93a3ccf..2cd98b8 100644 --- a/modules/com/saurik/substrate/MS.cy +++ b/modules/com/saurik/substrate/MS.cy @@ -36,13 +36,10 @@ if (CYHandleServer == null) { var info = new Dl_info; if (dladdr(CYHandleServer, info) == 0) { exports.error = dlerror(); - free(info); return; } var path = info->dli_fname; -free(info); - var slash = path.lastIndexOf('/'); if (slash == -1) return; -- 2.50.0