diff options
author | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-06-13 19:21:50 +0000 |
---|---|---|
committer | thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2008-06-13 19:21:50 +0000 |
commit | c53ec5520e39096e0804ce8d89a21378c0904481 (patch) | |
tree | d36a0055b59b1376d86c4ba4a01f9c479c2101a7 /Foundation/GTMNSString+HTML.m | |
parent | 80d493da05c8d461d74bfaa919ffc487be03ffe6 (diff) |
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.
Diffstat (limited to 'Foundation/GTMNSString+HTML.m')
-rw-r--r-- | Foundation/GTMNSString+HTML.m | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Foundation/GTMNSString+HTML.m b/Foundation/GTMNSString+HTML.m index 5178ba9..6853df0 100644 --- a/Foundation/GTMNSString+HTML.m +++ b/Foundation/GTMNSString+HTML.m @@ -357,8 +357,8 @@ static HTMLEscapeMap gUnicodeHTMLEscapeMap[] = { // Utility function for Bsearching table above static int EscapeMapCompare(const void *ucharVoid, const void *mapVoid) { - unichar *uchar = (unichar*)ucharVoid; - HTMLEscapeMap *map = (HTMLEscapeMap*)mapVoid; + const unichar *uchar = (const unichar*)ucharVoid; + const HTMLEscapeMap *map = (const HTMLEscapeMap*)mapVoid; int val; if (*uchar > map->uchar) { val = 1; @@ -387,18 +387,16 @@ static int EscapeMapCompare(const void *ucharVoid, const void *mapVoid) { // it's so short that it isn't really worth trying to share. const unichar *buffer = CFStringGetCharactersPtr((CFStringRef)self); 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 } - [self getCharacters:(void*)buffer]; - [NSData dataWithBytesNoCopy:(void*)buffer length:memsize]; + [self getCharacters:[data mutableBytes]]; + buffer = [data bytes]; } if (!buffer || !data2) { |