diff options
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m | 3 | ||||
-rw-r--r-- | Source/SPCopyTable.m | 13 | ||||
-rw-r--r-- | Source/SPDataAdditions.m | 3 | ||||
-rw-r--r-- | Source/SPEncodingPopupAccessory.m | 3 | ||||
-rw-r--r-- | Source/SPSQLExporter.m | 5 | ||||
-rw-r--r-- | Source/SPSplitView.m | 11 | ||||
-rw-r--r-- | Source/SPStringAdditions.m | 3 | ||||
-rw-r--r-- | Source/SPTableContent.m | 7 |
8 files changed, 28 insertions, 20 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m index 705b3daf..930180da 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m @@ -32,6 +32,7 @@ #import "SPMySQL Private APIs.h" #import "SPMySQLArrayAdditions.h" #include <pthread.h> +#include <stdlib.h> static id NSNullPointer; @@ -360,7 +361,7 @@ typedef struct st_spmysqlstreamingrowdata { newRowStore->nextRow = NULL; // Set up the row data store - a char* - and copy in the data if there is any. - newRowStore->data = malloc(sizeOfChar * rowDataLength); + newRowStore->data = calloc(rowDataLength, sizeOfChar); for (i = 0; i < numberOfFields; i++) { if (theRow[i] != NULL) { memcpy(newRowStore->data+dataCopiedLength, theRow[i], fieldLengths[i]); diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index 439ff84d..06d94f0b 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -53,6 +53,7 @@ #import <SPMySQL/SPMySQL.h> #import "pthread.h" +#include <stdlib.h> NSInteger SPEditMenuCopy = 2001; NSInteger SPEditMenuCopyWithColumns = 2002; @@ -171,7 +172,7 @@ static const NSInteger kBlobAsImageFile = 4; id cellData = nil; // Create an array of table column mappings for fast iteration - NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger)); + NSUInteger *columnMappings = calloc(numColumns, sizeof(NSUInteger)); for ( c = 0; c < numColumns; c++ ) columnMappings[c] = (NSUInteger)[[NSArrayObjectAtIndex(columns, c) identifier] integerValue]; @@ -309,7 +310,7 @@ static const NSInteger kBlobAsImageFile = 4; id cellData = nil; // Create an array of table column mappings for fast iteration - NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger)); + NSUInteger *columnMappings = calloc(numColumns, sizeof(NSUInteger)); for ( c = 0; c < numColumns; c++ ) columnMappings[c] = (NSUInteger)[[NSArrayObjectAtIndex(columns, c) identifier] integerValue]; @@ -447,8 +448,8 @@ static const NSInteger kBlobAsImageFile = 4; } // Create arrays of table column mappings and types for fast iteration - NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger)); - NSUInteger *columnTypes = malloc(numColumns * sizeof(NSUInteger)); + NSUInteger *columnMappings = calloc(numColumns, sizeof(NSUInteger)); + NSUInteger *columnTypes = calloc(numColumns, sizeof(NSUInteger)); for (c = 0; c < numColumns; c++) { @@ -628,7 +629,7 @@ static const NSInteger kBlobAsImageFile = 4; id cellData = nil; // Create an array of table column mappings for fast iteration - NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger)); + NSUInteger *columnMappings = calloc(numColumns, sizeof(NSUInteger)); for ( c = 0; c < numColumns; c++ ) columnMappings[c] = (NSUInteger)[[NSArrayObjectAtIndex(columns, c) identifier] integerValue]; @@ -1373,7 +1374,7 @@ static const NSInteger kBlobAsImageFile = 4; // Create an array of table column mappings for fast iteration NSArray *columns = [self tableColumns]; NSUInteger numColumns = [columns count]; - NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger)); + NSUInteger *columnMappings = calloc(numColumns, sizeof(NSUInteger)); NSUInteger c; for ( c = 0; c < numColumns; c++ ) columnMappings[c] = (NSUInteger)[[NSArrayObjectAtIndex(columns, c) identifier] integerValue]; diff --git a/Source/SPDataAdditions.m b/Source/SPDataAdditions.m index 80ca72a1..e9eaa927 100644 --- a/Source/SPDataAdditions.m +++ b/Source/SPDataAdditions.m @@ -37,6 +37,7 @@ #include <zlib.h> #include <openssl/aes.h> #include <openssl/sha.h> +#include <stdlib.h> @implementation NSData (SPDataAdditions) @@ -247,7 +248,7 @@ buffLength = totalLength - i; } - buffer = (unsigned char*) malloc( sizeof(unsigned char) * buffLength + 1); + buffer = (unsigned char*) calloc(buffLength + 1, sizeof(unsigned char)); [self getBytes:buffer range:NSMakeRange(i, buffLength)]; diff --git a/Source/SPEncodingPopupAccessory.m b/Source/SPEncodingPopupAccessory.m index 6c0df107..6c6be255 100644 --- a/Source/SPEncodingPopupAccessory.m +++ b/Source/SPEncodingPopupAccessory.m @@ -29,6 +29,7 @@ // More info at <https://github.com/sequelpro/sequelpro> #import "SPEncodingPopupAccessory.h" +#include <stdlib.h> @implementation SPEncodingPopupAccessory @@ -92,7 +93,7 @@ static int encodingCompare(const void *firstPtr, const void *secondPtr) while (cfEncodings[num] != kCFStringEncodingInvalidId) num++; - tmp = malloc(sizeof(CFStringEncoding) * num); + tmp = calloc(num, sizeof(CFStringEncoding)); memcpy(tmp, cfEncodings, sizeof(CFStringEncoding) * num); diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m index 079ea8b9..f72bb72f 100644 --- a/Source/SPSQLExporter.m +++ b/Source/SPSQLExporter.m @@ -37,6 +37,7 @@ #import "RegexKitLite.h" #import <SPMySQL/SPMySQL.h> +#include <stdlib.h> @interface SPSQLExporter () @@ -293,8 +294,8 @@ NSMutableArray *rawColumnNames = [NSMutableArray arrayWithCapacity:colCount]; NSMutableArray *queryColumnDetails = [NSMutableArray arrayWithCapacity:colCount]; - useRawDataForColumnAtIndex = malloc(sizeof(BOOL) * colCount); - useRawHexDataForColumnAtIndex = malloc(sizeof(BOOL) * colCount); + useRawDataForColumnAtIndex = calloc(colCount, sizeof(BOOL)); + useRawHexDataForColumnAtIndex = calloc(colCount, sizeof(BOOL)); // Determine whether raw data can be used for each column during processing - safe numbers and hex-encoded data. for (j = 0; j < colCount; j++) diff --git a/Source/SPSplitView.m b/Source/SPSplitView.m index ed87f3c0..467e0cd1 100644 --- a/Source/SPSplitView.m +++ b/Source/SPSplitView.m @@ -30,6 +30,7 @@ #import "SPSplitView.h" #import "SPDateAdditions.h" +#include <stdlib.h> @interface SPSplitView (Private_API) @@ -797,9 +798,9 @@ float viewLength, sizeDifference, totalGive, changedLength; float totalCurrentSize = 0; float resizeProportionTotal = 1.f; - float *originalSizes = malloc(subviewCount * sizeof(float)); - float *minSizes = malloc(subviewCount * sizeof(float)); - float *maxSizes = malloc(subviewCount * sizeof(float)); + float *originalSizes = calloc(subviewCount, sizeof(float)); + float *minSizes = calloc(subviewCount, sizeof(float)); + float *maxSizes = calloc(subviewCount, sizeof(float)); BOOL *sizesCalculated; float *resizeProportions; NSMutableArray *outputSizes = [NSMutableArray arrayWithCapacity:subviewCount]; @@ -906,8 +907,8 @@ } // Set up some arrays for fast lookups - sizesCalculated = malloc(subviewCount * sizeof(BOOL)); - resizeProportions = malloc(subviewCount * sizeof(float)); + sizesCalculated = calloc(subviewCount, sizeof(BOOL)); + resizeProportions = calloc(subviewCount, sizeof(float)); // Prepopulate them for (i = 0; i < subviewCount; i++) { diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index ebd81a54..26de14d7 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -30,6 +30,7 @@ #import "SPStringAdditions.h" #import "RegexKitLite.h" +#include <stdlib.h> static NSInteger _smallestOf(NSInteger a, NSInteger b, NSInteger c); @@ -405,7 +406,7 @@ static NSInteger _smallestOf(NSInteger a, NSInteger b, NSInteger c); if (n++ != 0 && m++ != 0) { - d = malloc(sizeof(NSInteger) * m * n); + d = calloc(m * n, sizeof(NSInteger)); for (k = 0; k < n; k++) { diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 4cd21bb1..113bda45 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -65,6 +65,7 @@ #import <pthread.h> #import <SPMySQL/SPMySQL.h> +#include <stdlib.h> #ifndef SP_CODA static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOperator"; @@ -908,7 +909,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper BOOL columnsFound = YES; NSArray *primaryKeyFieldNames = [selectionToRestore objectForKey:@"keys"]; NSUInteger primaryKeyFieldCount = [primaryKeyFieldNames count]; - NSUInteger *primaryKeyFieldIndexes = malloc(primaryKeyFieldCount * sizeof(NSUInteger)); + NSUInteger *primaryKeyFieldIndexes = calloc(primaryKeyFieldCount, sizeof(NSUInteger)); for (NSUInteger i = 0; i < primaryKeyFieldCount; i++) { primaryKeyFieldIndexes[i] = [[tableDataInstance columnNames] indexOfObject:[primaryKeyFieldNames objectAtIndex:i]]; if (primaryKeyFieldIndexes[i] == NSNotFound) { @@ -3696,7 +3697,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Set up an array of the column indexes to store NSUInteger primaryKeyFieldCount = [primaryKeyFieldNames count]; - NSUInteger *primaryKeyFieldIndexes = malloc(sizeof(NSUInteger) * primaryKeyFieldCount); + NSUInteger *primaryKeyFieldIndexes = calloc(primaryKeyFieldCount, sizeof(NSUInteger)); BOOL problemColumns = NO; for (NSUInteger i = 0; i < primaryKeyFieldCount; i++) { primaryKeyFieldIndexes[i] = [[tableDataInstance columnNames] indexOfObject:[primaryKeyFieldNames objectAtIndex:i]]; @@ -3716,7 +3717,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper // Only proceed with key-based selection if there were no problem columns if (!problemColumns) { NSIndexSet *selectedRowIndexes = [tableContentView selectedRowIndexes]; - NSUInteger *indexBuffer = malloc(sizeof(NSUInteger) * [selectedRowIndexes count]); + NSUInteger *indexBuffer = calloc([selectedRowIndexes count], sizeof(NSUInteger)); NSUInteger indexCount = [selectedRowIndexes getIndexes:indexBuffer maxCount:[selectedRowIndexes count] inIndexRange:NULL]; NSMutableDictionary *selectedRowLookupTable = [NSMutableDictionary dictionaryWithCapacity:indexCount]; |