aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m27
1 files changed, 16 insertions, 11 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
index 465221fe..bdb271fe 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
@@ -226,14 +226,12 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf);
id cellData = nil;
char *theData = NULL;
- // In fully streaming mode, copy across the data for the MYSQL_ROW
+ // In fully streaming mode, get a reference to the data for the MYSQL_ROW
if (fullyStreaming) {
if (theRow[i] == NULL) {
cellData = [NSNull null];
} else {
- theData = calloc(sizeof(char), fieldLengths[i]+1);
- memcpy(theData, theRow[i], fieldLengths[i]);
- theData[fieldLengths[i]] = '\0';
+ theData = theRow[i];
}
// In cached-streaming mode, use a reference to the downloaded data
@@ -281,7 +279,7 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf);
}
// For string data, convert to text
else {
- cellData = [NSString stringWithCString:theData encoding:mEncoding];
+ cellData = [[[NSString alloc] initWithBytes:theData length:fieldLengths[i] encoding:mEncoding] autorelease];
}
break;
@@ -328,9 +326,6 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf);
break;
}
- // Free the data if it was originally allocated
- if (fullyStreaming) free(theData);
-
// If a creator returned a nil object, replace with NSNull
if (cellData == nil) cellData = [NSNull null];
}
@@ -435,12 +430,22 @@ void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf);
void _bytes2bin(Byte *n, NSUInteger nbytes, NSUInteger len, char *buf)
{
+ // NSUInteger i = 0;
+ // nbytes--;
+ // while (++i <= len)
+ // buf[len - i] = ( (n[nbytes - (i >> 3)] >> (i & 0x7)) & 1 ) ? '1' : '0';
+ //
+ // buf[len] = '\0';
+ // ↑ why does this code not working anymore?
+
NSUInteger i = 0;
nbytes--;
- while (++i <= len)
- buf[len - i] = ( (n[nbytes - (i >> 3)] >> (i & 0x7)) & 1 ) ? '1' : '0';
+ len--;
+ while (i <= len)
+ buf[len - i++] = ( (n[nbytes - (i >> 3)] >> (i & 0x7)) & 1 ) ? '1' : '0';
+
+ buf[len+1] = '\0';
- buf[len] = '\0';
}
/**