Fix leaks in mac DumpRenderTree.
* DumpRenderTree/FrameLoadDelegate.mm:
(-[FrameLoadDelegate init]): Initalize in the correct order.
(-[FrameLoadDelegate processWork:]): Delete WorkQueueItem's after dequeueing them.
* DumpRenderTree/LayoutTestController.cpp:
(decodeHostNameCallback): Put return value in a temporary JSRetainPtr to ensure it gets released.
(encodeHostNameCallback): ditto.
* DumpRenderTree/LayoutTestController.h:
* DumpRenderTree/LayoutTestControllerMac.mm:
(LayoutTestController::copyDecodedHostName): Rename function to signal that it follows the Create rule.
(LayoutTestController::copyEncodedHostName): ditto
(LayoutTestController::queueLoad): Use a JSRetainPtr to ensure the url gets released.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25529
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-09-12 Sam Weinig <sam@webkit.org>
+
+ Reviewed by Stephanie.
+
+ Fix leaks in mac DumpRenderTree.
+
+ * DumpRenderTree/FrameLoadDelegate.mm:
+ (-[FrameLoadDelegate init]): Initalize in the correct order.
+ (-[FrameLoadDelegate processWork:]): Delete WorkQueueItem's after dequeueing them.
+ * DumpRenderTree/LayoutTestController.cpp:
+ (decodeHostNameCallback): Put return value in a temporary JSRetainPtr to ensure it gets released.
+ (encodeHostNameCallback): ditto.
+ * DumpRenderTree/LayoutTestController.h:
+ * DumpRenderTree/LayoutTestControllerMac.mm:
+ (LayoutTestController::copyDecodedHostName): Rename function to signal that it follows the Create rule.
+ (LayoutTestController::copyEncodedHostName): ditto
+ (LayoutTestController::queueLoad): Use a JSRetainPtr to ensure the url gets released.
+
2007-09-12 Kevin McCullough <kmccullough@apple.com>
Reviewed by Darin.
- (id)init
{
- layoutTestContoller = new LayoutTestController();
- return [super init];
+ if ((self = [super init]))
+ layoutTestContoller = new LayoutTestController;
+ return self;
}
- (void)dealloc
WorkQueueItem* item = WorkQueue::shared()->dequeue();
ASSERT(item);
item->invoke();
+ delete item;
}
// if we didn't start a new load, then we finished all the commands, so we're ready to dump state
return JSValueMakeUndefined(context);
}
-#pragma mark Require implementation
-
static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
// Has mac implementation
ASSERT(!*exception);
LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
- return JSValueMakeString(context, controller->decodeHostName(name.get()));
+ JSRetainPtr<JSStringRef> decodedHostName(Adopt, controller->copyDecodedHostName(name.get()));
+ return JSValueMakeString(context, decodedHostName.get());
}
static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
ASSERT(!*exception);
LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
- return JSValueMakeString(context, controller->encodeHostName(name.get()));
+ JSRetainPtr<JSStringRef> encodedHostName(Adopt, controller->copyEncodedHostName(name.get()));
+ return JSValueMakeString(context, encodedHostName.get());
}
static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
void addFileToPasteboardOnDrag();
void addDisallowedURL(JSStringRef url);
void clearBackForwardList();
- JSStringRef decodeHostName(JSStringRef name);
- JSStringRef encodeHostName(JSStringRef name);
+ JSStringRef copyDecodedHostName(JSStringRef name);
+ JSStringRef copyEncodedHostName(JSStringRef name);
void display();
void keepWebHistory();
void notifyDone();
[item release];
}
-JSStringRef LayoutTestController::decodeHostName(JSStringRef name)
+JSStringRef LayoutTestController::copyDecodedHostName(JSStringRef name)
{
RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
NSString *nameNS = (NSString *)nameCF.get();
return JSStringCreateWithCFString((CFStringRef)[nameNS _web_decodeHostName]);
}
-JSStringRef LayoutTestController::encodeHostName(JSStringRef name)
+JSStringRef LayoutTestController::copyEncodedHostName(JSStringRef name)
{
RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
NSString *nameNS = (NSString *)nameCF.get();
NSURL *nsurl = [NSURL URLWithString:urlNS relativeToURL:[[[mainFrame dataSource] response] URL]];
NSString* nsurlString = [nsurl absoluteString];
- WorkQueue::shared()->queue(new LoadItem(JSStringCreateWithUTF8CString([nsurlString UTF8String]), target));
+ JSRetainPtr<JSStringRef> absoluteURL(Adopt, JSStringCreateWithUTF8CString([nsurlString UTF8String]));
+ WorkQueue::shared()->queue(new LoadItem(absoluteURL.get(), target));
}
void LayoutTestController::queueReload()