Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

copying only 1 char and moving a free call

  • Loading branch information...
commit be2f3c3a19fcf6d98168fdaaefba1fe4040cf825 1 parent 4d35530
@Machx authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 Source/CWTrie.m
View
6 Source/CWTrie.m
@@ -96,7 +96,9 @@ -(id)objectValueForKey:(NSString *)aKey
const char *key = ([self caseSensitive]) ? [aKey UTF8String] : [[aKey lowercaseString] UTF8String];
while (*key) {
- NSString *aChar = [NSString stringWithUTF8String:key];
+ char *cChar = strndup(key, 1);
+ NSString *aChar = [NSString stringWithUTF8String:cChar];
+ free(cChar);
CWTrieNode *node = [currentNode nodeForCharacter:aChar];
if (node) {
currentNode = node;
@@ -118,6 +120,7 @@ -(void)setObjectValue:(id)aObject
while (*key) {
char *cChar = strndup(key, 1);
NSString *aChar = [NSString stringWithUTF8String:(const char *)cChar];
+ free(cChar);
CWTrieNode *node = [currentNode nodeForCharacter:aChar];
if (node) {
currentNode = node;
@@ -127,7 +130,6 @@ -(void)setObjectValue:(id)aObject
[currentNode.children addObject:aNode];
currentNode = aNode;
}
- free(cChar);
key++;
}
Please sign in to comment.
Something went wrong with that request. Please try again.