Skip to content

Commit

Permalink
Use dataWithBytes instead of memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmryan committed Jun 3, 2014
1 parent 251fe30 commit aada6f6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/fmdb/FMResultSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@ - (NSData*)dataForColumnIndex:(int)columnIdx {
}

int dataSize = sqlite3_column_bytes([_statement statement], columnIdx);
const char *dataBuffer = sqlite3_column_blob([_statement statement], columnIdx);

NSMutableData *data = [NSMutableData dataWithLength:(NSUInteger)dataSize];

memcpy([data mutableBytes], sqlite3_column_blob([_statement statement], columnIdx), (size_t)dataSize);
if (dataBuffer == NULL) {
return nil;
}

return data;
return [NSData dataWithBytes:(const void *)dataBuffer length:(NSUInteger)dataSize];
}


Expand Down

0 comments on commit aada6f6

Please sign in to comment.