aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-04-23 17:15:18 +0000
committerrowanbeentje <rowan@beent.je>2011-04-23 17:15:18 +0000
commitd60880e78188b4ef7cc2e73106eb980af3c13642 (patch)
tree1b3e064f9909c9e8d9f5afd7342c49b671dbb048 /Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
parent555cb252a3e42d0df5835a18df4abbe1a0b0725a (diff)
downloadsequelpro-d60880e78188b4ef7cc2e73106eb980af3c13642.tar.gz
sequelpro-d60880e78188b4ef7cc2e73106eb980af3c13642.tar.bz2
sequelpro-d60880e78188b4ef7cc2e73106eb980af3c13642.zip
Alter result string processing to use returned string length and not null-terminated string processing:
- This fixes issues caused by null characters in strings - addressing Issue 1029 - Also appears to be a few percent faster than the old approach when processing lots of short strings - Allows significant simplification of MCPResult and low-memory MCPStreamingResult code, avoiding a memory copy; this also gives a significant speedup and can actually make full streaming in MCPStreamingResult faster than "fast streaming". The code will be reviewed further in future to improve on the gains seen here.
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPResult.m')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPResult.m9
1 files changed, 2 insertions, 7 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
index 53066c14..84793e44 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m
@@ -419,10 +419,7 @@ const OUR_CHARSET our_charsets60[] =
if (theRow[i] == NULL) {
theCurrentObj = [NSNull null];
} else {
- char *theData = calloc(sizeof(char),theLengths[i]+1);
- //char *theUselLess;
- memcpy(theData, theRow[i],theLengths[i]);
- theData[theLengths[i]] = '\0';
+ char *theData = theRow[i];
switch (theField[i].type) {
case FIELD_TYPE_TINY:
@@ -444,7 +441,7 @@ const OUR_CHARSET our_charsets60[] =
case FIELD_TYPE_SET:
case FIELD_TYPE_ENUM:
case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is...
- theCurrentObj = [NSString stringWithCString:theData encoding:mEncoding];
+ theCurrentObj = [[[NSString alloc] initWithBytes:theData length:theLengths[i] encoding:mEncoding] autorelease];
break;
case FIELD_TYPE_BIT:
@@ -479,8 +476,6 @@ const OUR_CHARSET our_charsets60[] =
break;
}
- free(theData);
-
// Some of the creators return nil object...
if (theCurrentObj == nil) {
theCurrentObj = [NSNull null];