Permalink
Browse files

Fix memory leak & remove unuse code

  • Loading branch information...
bang590 committed Sep 20, 2015
1 parent 4dcbb84 commit 799d70c5a973265790fecf623a6639be39a59459
Showing with 3 additions and 6 deletions.
  1. +3 −6 JSPatch/JPEngine.m
View
@@ -629,12 +629,7 @@ static void overrideMethod(Class cls, NSString *selectorName, JSValue *function,
{
SEL selector = NSSelectorFromString(selectorName);
NSMethodSignature *methodSignature;
if (typeDescription) {
methodSignature = [NSMethodSignature signatureWithObjCTypes:typeDescription];
} else {
methodSignature = [cls instanceMethodSignatureForSelector:selector];
if (!typeDescription) {
Method method = class_getInstanceMethod(cls, selector);
typeDescription = (char *)method_getTypeEncoding(method);
}
@@ -647,6 +642,7 @@ static void overrideMethod(Class cls, NSString *selectorName, JSValue *function,
//In some cases that returns struct, we should use the '_stret' API:
//http://sealiesoftware.com/blog/archive/2008/10/30/objc_explain_objc_msgSend_stret.html
//NSMethodSignature knows the detail but has no API to return, we can only get the info from debugDescription.
NSMethodSignature *methodSignature = [NSMethodSignature signatureWithObjCTypes:typeDescription];
if ([methodSignature.debugDescription rangeOfString:@"is special struct return? YES"].location != NSNotFound) {
msgForwardIMP = (IMP)_objc_msgForward_stret;
}
@@ -1129,6 +1125,7 @@ static void getStructDataWithDict(void *structData, NSDictionary *dict, NSDictio
_type *val = malloc(size); \
memcpy(val, structData + position, size); \
[dict setObject:@(*val) forKey:itemKeys[i]]; \
free(val); \
position += size; \
break; \
}

0 comments on commit 799d70c

Please sign in to comment.