]> granicus.if.org Git - graphviz/commitdiff
refactor calls to NEW that can tolerate failure into calloc
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 16 Jun 2020 00:06:27 +0000 (17:06 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 22 Jun 2020 23:39:21 +0000 (16:39 -0700)
We are about to make the NEW wrapper exit on allocation failure, so this
preserves the existing semantics of allowing these calls to handle allocation
failure locally.

lib/label/index.c

index 74fdb2857e275406972ad8b194ac9fdbd11a506b..bd769a6990586ba2192c330b02e31a9a5b61c970 100644 (file)
@@ -22,7 +22,7 @@ LeafList_t *RTreeNewLeafList(Leaf_t * lp)
 {
     LeafList_t *llp;
 
-    if ((llp = NEW(LeafList_t))) {
+    if ((llp = calloc(1, sizeof(LeafList_t)))) {
        llp->leaf = lp;
        llp->next = 0;
     }
@@ -57,7 +57,7 @@ void RTreeLeafListFree(LeafList_t * llp)
  */
 static struct ListNode *RTreeNewListNode(void)
 {
-    return NEW(struct ListNode);
+    return calloc(1, sizeof(struct ListNode));
 }
 
 #if UNUSED
@@ -86,7 +86,7 @@ RTree_t *RTreeOpen()
 {
     RTree_t *rtp;
 
-    if ((rtp = NEW(RTree_t)))
+    if ((rtp = calloc(1, sizeof(RTree_t))))
        rtp->root = RTreeNewIndex(rtp);
     return rtp;
 }