Revision: 28573
          http://sourceforge.net/p/bibdesk/svn/28573
Author:   hofman
Date:     2024-01-07 17:26:39 +0000 (Sun, 07 Jan 2024)
Log Message:
-----------
Don't use macros to destroy CF objects and malloced pointers

Modified Paths:
--------------
    trunk/bibdesk/BDSKFileSearch.m
    trunk/bibdesk/BDSKFileSearchIndex.m
    trunk/bibdesk/BDSKItemSearchIndexes.m
    trunk/bibdesk/BDSKLinkedFile.m
    trunk/bibdesk/BDSKNotesSearchIndex.m
    trunk/bibdesk/BDSKPersistentSearch.m
    trunk/bibdesk/BDSKVersionNumber.m
    trunk/bibdesk/Bibdesk_Prefix.pch

Modified: trunk/bibdesk/BDSKFileSearch.m
===================================================================
--- trunk/bibdesk/BDSKFileSearch.m      2024-01-07 17:15:36 UTC (rev 28572)
+++ trunk/bibdesk/BDSKFileSearch.m      2024-01-07 17:26:39 UTC (rev 28573)
@@ -289,9 +289,12 @@
 
 - (void)dealloc
 {
-    BDSKFREEDESTROY(ids);
-    BDSKFREEDESTROY(docs);
-    BDSKFREEDESTROY(scores);
+    if (ids) free((void *)ids);
+    ids = NULL;
+    if (docs) free((void *)docs);
+    docs = NULL;
+    if (scores) free((void *)scores);
+    scores = NULL;
     [super dealloc];
 }
 

Modified: trunk/bibdesk/BDSKFileSearchIndex.m
===================================================================
--- trunk/bibdesk/BDSKFileSearchIndex.m 2024-01-07 17:15:36 UTC (rev 28572)
+++ trunk/bibdesk/BDSKFileSearchIndex.m 2024-01-07 17:26:39 UTC (rev 28573)
@@ -135,8 +135,10 @@
     [rwLock unlock];
     BDSKDESTROY(rwLock);
     BDSKDESTROY(signatures);
-    BDSKCFDESTROY(skIndex);
-    BDSKCFDESTROY(indexData);
+    if(skIndex) CFRelease(skIndex);
+    skIndex = NULL;
+    if (indexData) CFRelease(indexData);
+    indexData = NULL;
     [super dealloc];
 }
 

Modified: trunk/bibdesk/BDSKItemSearchIndexes.m
===================================================================
--- trunk/bibdesk/BDSKItemSearchIndexes.m       2024-01-07 17:15:36 UTC (rev 
28572)
+++ trunk/bibdesk/BDSKItemSearchIndexes.m       2024-01-07 17:26:39 UTC (rev 
28573)
@@ -76,8 +76,10 @@
 }
 
 - (void)dealloc {
-    BDSKCFDESTROY(searchIndexes);
-    BDSKCFDESTROY(indexesToFlush);
+    if (searchIndexes) CFRelease(searchIndexes);
+    searchIndexes = NULL;
+    if (indexesToFlush) CFRelease(indexesToFlush);
+    indexesToFlush = NULL;
     [super dealloc];
 }
 

Modified: trunk/bibdesk/BDSKLinkedFile.m
===================================================================
--- trunk/bibdesk/BDSKLinkedFile.m      2024-01-07 17:15:36 UTC (rev 28572)
+++ trunk/bibdesk/BDSKLinkedFile.m      2024-01-07 17:26:39 UTC (rev 28573)
@@ -594,12 +594,16 @@
 }
 
 - (void)dealloc {
-    BDSKFREEDESTROY(fileRef);
+    if (fileRef) free((void *)fileRef);
+    fileRef = NULL;
     [super dealloc];
 }
 
 - (void)setFileRef:(FSRef *)aRef {
-    BDSKFREEDESTROY(fileRef);
+    if (fileRef) {
+        free((void *)fileRef);
+        fileRef = NULL;
+    }
     if (aRef != NULL) {
         FSRef *newRef = (FSRef *)malloc(sizeof(FSRef));
         if (newRef) {
@@ -684,9 +688,11 @@
     
     if (fileRef != nil) {
         aURL = BDSKURLFromFSRef(fileRef);
-        if (aURL == nil)
+        if (aURL == nil && fileRef) {
             // fileRef was invalid, try to update it
-            BDSKFREEDESTROY(fileRef);
+            free((void *)fileRef);
+            fileRef = NULL;
+        }
     }
     if (aURL == nil) {
         // fileRef was nil or invalid
@@ -749,7 +755,10 @@
             }
         } else {
             // the fileRef was invalid, reset it and update
-            BDSKFREEDESTROY(fileRef);
+            if (fileRef) {
+                free((void *)fileRef);
+                fileRef = NULL;
+            }
             [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/BDSKNotesSearchIndex.m
===================================================================
--- trunk/bibdesk/BDSKNotesSearchIndex.m        2024-01-07 17:15:36 UTC (rev 
28572)
+++ trunk/bibdesk/BDSKNotesSearchIndex.m        2024-01-07 17:26:39 UTC (rev 
28573)
@@ -86,10 +86,11 @@
 - (void)dealloc
 {
     delegate = nil;
+    BDSKDESTROY(fileManager);
     BDSKDESTROY(queue);
     BDSKDESTROY(lock);
-    BDSKCFDESTROY(skIndex);
-    BDSKDESTROY(fileManager);
+    if (skIndex) CFRelease(skIndex);
+    skIndex = NULL;
     [super dealloc];
 }
 

Modified: trunk/bibdesk/BDSKPersistentSearch.m
===================================================================
--- trunk/bibdesk/BDSKPersistentSearch.m        2024-01-07 17:15:36 UTC (rev 
28572)
+++ trunk/bibdesk/BDSKPersistentSearch.m        2024-01-07 17:26:39 UTC (rev 
28573)
@@ -79,7 +79,8 @@
                    context:&BDSKPersistentSearchDefaultsObservationContext];
     }
     @catch (id e) {}
-    BDSKCFDESTROY(queries);
+    if (queries) CFRelease(queries);
+    queries = NULL;
     [super dealloc];
 }
 

Modified: trunk/bibdesk/BDSKVersionNumber.m
===================================================================
--- trunk/bibdesk/BDSKVersionNumber.m   2024-01-07 17:15:36 UTC (rev 28572)
+++ trunk/bibdesk/BDSKVersionNumber.m   2024-01-07 17:26:39 UTC (rev 28573)
@@ -173,7 +173,8 @@
 {
     BDSKDESTROY(originalVersionString);
     BDSKDESTROY(cleanVersionString);
-    BDSKFREEDESTROY(components);
+    if (components) free((void *)components);
+    components = NULL;
     [super dealloc];
 }
 

Modified: trunk/bibdesk/Bibdesk_Prefix.pch
===================================================================
--- trunk/bibdesk/Bibdesk_Prefix.pch    2024-01-07 17:15:36 UTC (rev 28572)
+++ trunk/bibdesk/Bibdesk_Prefix.pch    2024-01-07 17:26:39 UTC (rev 28573)
@@ -75,7 +75,5 @@
         } while (0)
 
     #define BDSKDESTROY(variable) do { [variable release]; variable = nil; } 
while (0)
-    #define BDSKCFDESTROY(variable) do { if (variable) CFRelease(variable); 
variable = NULL; } while (0)
-    #define BDSKFREEDESTROY(variable) do { if (variable) free((void 
*)variable); variable = NULL; } while (0)
 
 #endif

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