From c53ec5520e39096e0804ce8d89a21378c0904481 Mon Sep 17 00:00:00 2001 From: thomasvl Date: Fri, 13 Jun 2008 19:21:50 +0000 Subject: Landing a log of AppleScript/AppleEvent support code. Landing GTMHTTPServer as a simple server but mainly for use in unittesting. _GTMCompileAssert for doing compile time assertions to GTMDefines.h Lots of improvments for UnitTesting, Dave's gonna put up a wiki page shortly with the full details of what can be done. --- Foundation/GTMNSString+XML.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'Foundation/GTMNSString+XML.m') diff --git a/Foundation/GTMNSString+XML.m b/Foundation/GTMNSString+XML.m index bc2f130..909a8f1 100644 --- a/Foundation/GTMNSString+XML.m +++ b/Foundation/GTMNSString+XML.m @@ -113,18 +113,16 @@ static NSString *AutoreleasedCloneForXML(NSString *src, BOOL escaping) { // it's so short that it isn't really worth trying to share. const UniChar *buffer = CFStringGetCharactersPtr((CFStringRef)src); if (!buffer) { - size_t memsize = length * sizeof(UniChar); - - // nope, alloc buffer and fetch the chars ourselves - buffer = malloc(memsize); - if (!buffer) { + // We want this buffer to be autoreleased. + NSMutableData *data = [NSMutableData dataWithLength:length * sizeof(UniChar)]; + if (!data) { // COV_NF_START - Memory fail case _GTMDevLog(@"couldn't alloc buffer"); return nil; // COV_NF_END } - [src getCharacters:(void*)buffer]; - [NSData dataWithBytesNoCopy:(void*)buffer length:memsize]; + [src getCharacters:[data mutableBytes]]; + buffer = [data bytes]; } const UniChar *goodRun = buffer; -- cgit v1.2.3