]> git.saurik.com Git - cycript.git/commitdiff
Memory allocated by new will be garbage collected.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 22 Dec 2015 01:50:44 +0000 (17:50 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 22 Dec 2015 01:50:44 +0000 (17:50 -0800)
Execute.cpp
modules/com/saurik/substrate/MS.cy

index e575f94c8207b48674a6bdd5920be4095a185610..0402829925f9a158f5b73579cf81b28a54cf41ac 100644 (file)
@@ -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<Pointer *>(JSObjectGetPrivate(pointer)));
+    value->value_ = value->pool_->malloc<void>(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 {
index 93a3ccfe88dbe6f3d2bcaa7f655312f908b20b22..2cd98b8eb6f9009125294193b358760dbad69303 100644 (file)
@@ -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;