]> granicus.if.org Git - graphviz/commitdiff
sparse DoubleLinkedList_new: use cgraph wrapper for allocation
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 18 Nov 2022 01:14:41 +0000 (17:14 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 31 Dec 2022 16:33:58 +0000 (08:33 -0800)
The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

lib/sparse/LinkedList.c

index 5bada8216162273ec2761e42fdedda9d32ab93d9..bf7389dbb907aacef36b6081e916dd0c6c07a338 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <cgraph/alloc.h>
 #include <sparse/LinkedList.h>
-#include <common/memory.h>
 
 SingleLinkedList SingleLinkedList_new(void *data){
   SingleLinkedList head = gv_alloc(sizeof(struct SingleLinkedList_struct));
@@ -70,11 +69,8 @@ void SingleLinkedList_print(SingleLinkedList head, void (*linkedlist_print)(void
 
 
 DoubleLinkedList DoubleLinkedList_new(void *data){
-  DoubleLinkedList head;
-  head = GNEW(struct DoubleLinkedList_struct);
+  DoubleLinkedList head = gv_alloc(sizeof(struct DoubleLinkedList_struct));
   head->data = data;
-  head->next = NULL;
-  head->prev = NULL;
   return head;
 }