Revision: 28532
          http://sourceforge.net/p/bibdesk/svn/28532
Author:   hofman
Date:     2024-01-04 10:18:09 +0000 (Thu, 04 Jan 2024)
Log Message:
-----------
use malloc/free instead of NSZone functions

Modified Paths:
--------------
    trunk/bibdesk/BDSKFileSearch.m
    trunk/bibdesk/BDSKLineTextField.m
    trunk/bibdesk/BDSKLinkedFile.m
    trunk/bibdesk/BDSKTask.m
    trunk/bibdesk/BDSKVersionNumber.m
    trunk/bibdesk/Bibdesk_Prefix.pch
    trunk/bibdesk/CFString_BDSKExtensions.m
    trunk/bibdesk/NSArray_BDSKExtensions.m
    trunk/bibdesk/NSString_BDSKExtensions.m

Modified: trunk/bibdesk/BDSKFileSearch.m
===================================================================
--- trunk/bibdesk/BDSKFileSearch.m      2024-01-04 10:15:48 UTC (rev 28531)
+++ trunk/bibdesk/BDSKFileSearch.m      2024-01-04 10:18:09 UTC (rev 28532)
@@ -289,9 +289,9 @@
 
 - (void)dealloc
 {
-    BDSKZONEDESTROY(ids);
-    BDSKZONEDESTROY(docs);
-    BDSKZONEDESTROY(scores);
+    BDSKFREEDESTROY(ids);
+    BDSKFREEDESTROY(docs);
+    BDSKFREEDESTROY(scores);
     [super dealloc];
 }
 

Modified: trunk/bibdesk/BDSKLineTextField.m
===================================================================
--- trunk/bibdesk/BDSKLineTextField.m   2024-01-04 10:15:48 UTC (rev 28531)
+++ trunk/bibdesk/BDSKLineTextField.m   2024-01-04 10:18:09 UTC (rev 28532)
@@ -47,7 +47,7 @@
     NSFont *font = [self font];
     CGFloat *height = heightTable ? NSMapGet(heightTable, font) : NULL;
     if (height == NULL) {
-        height = NSZoneMalloc(NULL, sizeof(CGFloat));
+        height = malloc(sizeof(CGFloat));
         *height = [[self font] defaultViewLineHeight];
         if (heightTable == nil)
             heightTable = NSCreateMapTable(NSObjectMapKeyCallBacks, 
NSOwnedPointerMapValueCallBacks, 0);

Modified: trunk/bibdesk/BDSKLinkedFile.m
===================================================================
--- trunk/bibdesk/BDSKLinkedFile.m      2024-01-04 10:15:48 UTC (rev 28531)
+++ trunk/bibdesk/BDSKLinkedFile.m      2024-01-04 10:18:09 UTC (rev 28532)
@@ -592,14 +592,14 @@
 }
 
 - (void)dealloc {
-    BDSKZONEDESTROY(fileRef);
+    BDSKFREEDESTROY(fileRef);
     [super dealloc];
 }
 
 - (void)setFileRef:(FSRef *)aRef {
-    BDSKZONEDESTROY(fileRef);
+    BDSKFREEDESTROY(fileRef);
     if (aRef != NULL) {
-        FSRef *newRef = (FSRef *)NSZoneMalloc(NULL, sizeof(FSRef));
+        FSRef *newRef = (FSRef *)malloc(sizeof(FSRef));
         if (newRef) {
             bcopy(aRef, newRef, sizeof(FSRef));
             fileRef = newRef;
@@ -688,7 +688,7 @@
         aURL = BDSKCreateURLFromFSRef(fileRef);
         if (aURL == nil)
             // fileRef was invalid, try to update it
-            BDSKZONEDESTROY(fileRef);
+            BDSKFREEDESTROY(fileRef);
     }
     if (aURL == nil) {
         // fileRef was nil or invalid
@@ -754,7 +754,7 @@
             [aURL release];
         } else {
             // the fileRef was invalid, reset it and update
-            BDSKZONEDESTROY(fileRef);
+            BDSKFREEDESTROY(fileRef);
             [self updateFileRef];
             if (fileRef == nil && aPath) {
                 // this can happen after an auto file to a volume, as the file 
is actually not moved but copied

Modified: trunk/bibdesk/BDSKTask.m
===================================================================
--- trunk/bibdesk/BDSKTask.m    2024-01-04 10:15:48 UTC (rev 28531)
+++ trunk/bibdesk/BDSKTask.m    2024-01-04 10:18:09 UTC (rev 28532)
@@ -90,7 +90,7 @@
 {
     self = [super init];
     if (self) {
-        _internal = NSZoneCalloc(NULL, 1, sizeof(struct BDSKTaskInternal));
+        _internal = calloc(1, sizeof(struct BDSKTaskInternal));
         memset(&_internal->_event, 0, sizeof(struct kevent));
         pthread_mutex_init(&_internal->_lock, NULL);
         _internal->_canNotify = 1;
@@ -205,7 +205,7 @@
     
     // only freed when the child exits, so the kevent callout always has a 
valid udata pointer
     pthread_mutex_destroy(&task->_internal->_lock);
-    NSZoneFree(NSZoneFromPointer(task->_internal), task->_internal);
+    free(task->_internal);
     task->_internal = NULL;
     
     // balance additional retain in _taskExited
@@ -229,9 +229,9 @@
     if (nil == str) return NULL;
     
     CFIndex len = 
CFStringGetMaximumSizeOfFileSystemRepresentation((CFStringRef)str);
-    char *cstr = NSZoneCalloc(NSDefaultMallocZone(), len, sizeof(char));
+    char *cstr = calloc( len, sizeof(char));
     if (CFStringGetFileSystemRepresentation((CFStringRef)str, cstr, len) == 
FALSE) {
-        NSZoneFree(NSDefaultMallocZone(), cstr);
+        free(cstr);
         cstr = NULL;
     }
     return cstr;
@@ -245,7 +245,7 @@
     char *workingDir = 
__BDSKCopyFileSystemRepresentation(_currentDirectoryPath);
     
     // fill with pointers to copied C strings
-    char **args = NSZoneCalloc(NULL, (argCount + 2), sizeof(char *));
+    char **args = calloc((argCount + 2), sizeof(char *));
     NSUInteger i;
     args[0] = __BDSKCopyFileSystemRepresentation(_launchPath);
     for (i = 0; i < argCount; i++) {
@@ -259,7 +259,7 @@
     NSDictionary *environment = [self environment];
     if (environment) {
         // fill with pointers to copied C strings
-        env = NSZoneCalloc(NULL, [environment count] + 1, sizeof(char *));
+        env = calloc([environment count] + 1, sizeof(char *));
         NSString *key;
         NSUInteger envIndex = 0;
         for (key in environment) {
@@ -424,13 +424,13 @@
         free(*freePtr++);
     }
     
-    NSZoneFree(NSZoneFromPointer(args), args);
+    free(args);
     if (*nsEnvironment != env) {
         freePtr = env;
         while (NULL != *freePtr) { 
             free(*freePtr++);
         }
-        NSZoneFree(NSZoneFromPointer(env), env);
+        free(env);
     }
     
 }
@@ -546,7 +546,7 @@
                 // runloop and source were freed in _disableNotification
                 NSParameterAssert(NULL == internal->_rl);
                 NSParameterAssert(NULL == internal->_rlsource);
-                NSZoneFree(NSZoneFromPointer(internal), internal);
+                free(internal);
                 
             }            
             

Modified: trunk/bibdesk/BDSKVersionNumber.m
===================================================================
--- trunk/bibdesk/BDSKVersionNumber.m   2024-01-04 10:15:48 UTC (rev 28531)
+++ trunk/bibdesk/BDSKVersionNumber.m   2024-01-04 10:18:09 UTC (rev 28532)
@@ -173,7 +173,7 @@
 {
     BDSKDESTROY(originalVersionString);
     BDSKDESTROY(cleanVersionString);
-    BDSKZONEDESTROY(components);
+    BDSKFREEDESTROY(components);
     [super dealloc];
 }
 

Modified: trunk/bibdesk/Bibdesk_Prefix.pch
===================================================================
--- trunk/bibdesk/Bibdesk_Prefix.pch    2024-01-04 10:15:48 UTC (rev 28531)
+++ trunk/bibdesk/Bibdesk_Prefix.pch    2024-01-04 10:18:09 UTC (rev 28532)
@@ -79,7 +79,7 @@
 
     #define BDSKDESTROY(variable) do { [variable release]; variable = nil; } 
while (0)
     #define BDSKCFDESTROY(variable) do { if (variable) CFRelease(variable); 
variable = NULL; } while (0)
-    #define BDSKZONEDESTROY(variable) do { if (variable) 
NSZoneFree(NSZoneFromPointer((void *)variable), (void *)variable); variable = 
NULL; } while (0)
+    #define BDSKFREEDESTROY(variable) do { if (variable) free((void 
*)variable); variable = NULL; } while (0)
     #define BDSKDISPATCHDESTROY(variable) do { if (variable) 
dispatch_release(variable); variable = NULL; } while (0)
 
 #endif

Modified: trunk/bibdesk/CFString_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/CFString_BDSKExtensions.m     2024-01-04 10:15:48 UTC (rev 
28531)
+++ trunk/bibdesk/CFString_BDSKExtensions.m     2024-01-04 10:18:09 UTC (rev 
28532)
@@ -62,7 +62,7 @@
 __attribute__((constructor))
 static void initializeStopwordCache(void)
 {
-    stopWordCache = NSZoneMalloc(NULL, sizeof(_BDSKStopWordCache));
+    stopWordCache = malloc(sizeof(_BDSKStopWordCache));
     stopWordCache->stopWords = NULL;
     stopWordCache->numberOfWords = 0;
     stopWordNotificationCallback(NULL, NULL, NULL, NULL, NULL);
@@ -74,7 +74,7 @@
 {
     CFNotificationCenterRemoveObserver(CFNotificationCenterGetLocalCenter(), 
stopWordCache, CFSTR("BDSKIgnoredSortTermsChangedNotification"), NULL);
     if (stopWordCache->stopWords) CFRelease(stopWordCache->stopWords);
-    NSZoneFree(NULL, stopWordCache);
+    free(stopWordCache);
 }
 
 static inline CFArrayRef __BDSKGetStopwords(void) { return 
stopWordCache->stopWords; }

Modified: trunk/bibdesk/NSArray_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSArray_BDSKExtensions.m      2024-01-04 10:15:48 UTC (rev 
28531)
+++ trunk/bibdesk/NSArray_BDSKExtensions.m      2024-01-04 10:18:09 UTC (rev 
28532)
@@ -465,7 +465,7 @@
             for(j = i + 1; j < bufLen && __BDCompareSortCacheValues(&buf[i], 
&buf[j]) == 0; j++);
             if(j - i > 1){
                 (*numRanges)++;
-                equalRanges = (NSRange *)NSZoneRealloc(NULL, equalRanges, 
(*numRanges) * sizeof(NSRange));
+                equalRanges = (NSRange *)realloc(equalRanges, (*numRanges) * 
sizeof(NSRange));
                 equalRanges[(*numRanges) - 1].location = i;
                 equalRanges[(*numRanges) - 1].length = j - i;
 //                NSLog(@"equalityRange of %@", 
NSStringFromRange(NSMakeRange(i, j-i)));
@@ -517,13 +517,13 @@
     size_t count = [self count];
     size_t size = sizeof(BDSortCacheValue);
     
-    BDSortCacheValue *cache = (BDSortCacheValue *)NSZoneMalloc(NULL, count * 
size);
+    BDSortCacheValue *cache = (BDSortCacheValue *)malloc(count * size);
     BDSortCacheValue aValue;
     
     NSUInteger i, sortIdx = 0, numberOfDescriptors = [sortDescriptors count];
     
     // first "equal range" is considered to be the entire array
-    NSRange *equalRanges = (NSRange *)NSZoneMalloc(NULL, 1 * sizeof(NSRange));
+    NSRange *equalRanges = (NSRange *)malloc(sizeof(NSRange));
     equalRanges[0].location = 0;
     equalRanges[0].length = count;
     NSUInteger numberOfEqualRanges = 1;
@@ -577,7 +577,7 @@
             for(rangeIdx = 0; rangeIdx < numberOfEqualRanges; rangeIdx++)
                 newEqualRanges = __BDFindEqualRanges(cache, 
equalRanges[rangeIdx], newEqualRanges, &newNumberOfRanges);
             
-            NSZoneFree(NULL, equalRanges);
+            free(equalRanges);
             equalRanges = newEqualRanges;
             numberOfEqualRanges = newNumberOfRanges;
         }
@@ -585,7 +585,7 @@
         __BDClearStatics();
     }
         
-    if(equalRanges) NSZoneFree(NULL, equalRanges);
+    if(equalRanges) free(equalRanges);
     
     // our array of structures is now sorted correctly, so we just loop 
through it and create an array with the contents
     [self removeAllObjects];
@@ -595,7 +595,7 @@
         [aValue.object release];
     }
     
-    NSZoneFree(NULL, cache);
+    free(cache);
 }
 
 @end

Modified: trunk/bibdesk/NSString_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSString_BDSKExtensions.m     2024-01-04 10:15:48 UTC (rev 
28531)
+++ trunk/bibdesk/NSString_BDSKExtensions.m     2024-01-04 10:18:09 UTC (rev 
28532)
@@ -160,7 +160,7 @@
     NSParameterAssert(rating >= 0 && rating <= MAX_RATING);
     static NSString **ratingStrings = NULL;
     if(ratingStrings == NULL){
-        ratingStrings = NSZoneMalloc(NULL, (MAX_RATING + 1) * sizeof(NSString 
*));
+        ratingStrings = malloc((MAX_RATING + 1) * sizeof(NSString *));
         NSInteger i = 0;
         NSMutableString *ratingString = [NSMutableString string];
         do {
@@ -1382,7 +1382,7 @@
     else
         destSize += ( destSize >> 1 );
     
-    unsigned char *dest = NSZoneMalloc(NULL, destSize);
+    unsigned char *dest = malloc(destSize);
     NSUInteger i, j = 0;
     
     for (i = 0; i < sourceSize; i++) {
@@ -1391,7 +1391,7 @@
         // Headroom: we may insert up to three bytes into destination.
         if (j + 3 >= destSize) {
             NSInteger newSize = destSize + ( destSize >> 1 );
-            dest = NSZoneRealloc(NULL, dest, newSize);
+            dest = realloc(dest, newSize);
             destSize = newSize;
         }
         
@@ -1405,7 +1405,7 @@
     }
     
     NSString *resultString = 
CFBridgingRelease(CFStringCreateWithBytes(kCFAllocatorDefault, dest, j, 
kCFStringEncodingASCII, FALSE));
-    NSZoneFree(NULL, dest);
+    malloc(dest);
     
     return resultString;
 }
@@ -1615,7 +1615,7 @@
     NSInteger length;
     
     length = [self length];
-    ptr = NSZoneMalloc(NULL, length * sizeof(unichar));
+    ptr = malloc(length * sizeof(unichar));
     void *originalPtr = ptr;
     end = ptr + length;
     [self getCharacters:ptr];
@@ -1651,7 +1651,7 @@
         ptr++;
     }
     APPEND_PREVIOUS();
-    NSZoneFree(NULL, originalPtr);
+    free(originalPtr);
     return result;
 }
 
@@ -1672,7 +1672,7 @@
     BOOL isQuoted, needsSpace;
     
     length = [self length];
-    ptr = NSZoneMalloc(NULL, length * sizeof(unichar));
+    ptr = malloc(length * sizeof(unichar));
     void *originalPtr = ptr;
     end = ptr + length;
     [self getCharacters:ptr];
@@ -1681,7 +1681,7 @@
     needsSpace = NO;
     
     if(isQuoted == NO && [self rangeOfCharacterFromSet:[NSCharacterSet 
characterSetWithCharactersInString:@"\n\r\t\","]].length == 0) {
-        NSZoneFree(NULL, originalPtr);
+        free(originalPtr);
         return self;
     }
     
@@ -1713,7 +1713,7 @@
         [result insertString:@"\"" atIndex:0];
         [result appendString:@"\""];
     }
-    NSZoneFree(NULL, originalPtr);
+    free(originalPtr);
     return result;
 }
 
@@ -1729,7 +1729,7 @@
     BOOL needsSpace;
     
     length = [self length];
-    ptr = NSZoneMalloc(NULL, length * sizeof(unichar));
+    ptr = malloc(length * sizeof(unichar));
     void *originalPtr = ptr;
     end = ptr + length;
     [self getCharacters:ptr];
@@ -1756,7 +1756,7 @@
         ptr++;
     }
     APPEND_PREVIOUS();
-    NSZoneFree(NULL, originalPtr);
+    free(originalPtr);
     return result;
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to