summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-12-10 02:20:24 +0100
committerGravatar Nikias Bassen2018-12-10 02:22:15 +0100
commit4de329327ce4aa175e8496d1bff8604bffb6c574 (patch)
tree0c5fce7e138756a2479acab5a3098fa12ea6971b /src
parent71dd25e14616bd261c3b6c80ff990cd1078266f6 (diff)
downloadlibplist-4de329327ce4aa175e8496d1bff8604bffb6c574.tar.gz
libplist-4de329327ce4aa175e8496d1bff8604bffb6c574.tar.bz2
Remove node_iterator and operate on node list directly to improve memory usage
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c5
-rw-r--r--src/plist.c11
-rw-r--r--src/xplist.c5
3 files changed, 6 insertions, 15 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 69f3dca..679a5e5 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -39,7 +39,6 @@
39#include "ptrarray.h" 39#include "ptrarray.h"
40 40
41#include <node.h> 41#include <node.h>
42#include <node_iterator.h>
43 42
44/* Magic marker and size. */ 43/* Magic marker and size. */
45#define BPLIST_MAGIC ((uint8_t*)"bplist") 44#define BPLIST_MAGIC ((uint8_t*)"bplist")
@@ -938,12 +937,10 @@ static void serialize_plist(node_t* node, void* data)
938 ptr_array_add(ser->objects, node); 937 ptr_array_add(ser->objects, node);
939 938
940 //now recurse on children 939 //now recurse on children
941 node_iterator_t *ni = node_iterator_create(node->children);
942 node_t *ch; 940 node_t *ch;
943 while ((ch = node_iterator_next(ni))) { 941 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
944 serialize_plist(ch, data); 942 serialize_plist(ch, data);
945 } 943 }
946 node_iterator_destroy(ni);
947 944
948 return; 945 return;
949} 946}
diff --git a/src/plist.c b/src/plist.c
index f62e6be..cd22ca6 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -36,7 +36,6 @@
36#endif 36#endif
37 37
38#include <node.h> 38#include <node.h>
39#include <node_iterator.h>
40#include <hashtable.h> 39#include <hashtable.h>
41 40
42extern void plist_xml_init(void); 41extern void plist_xml_init(void);
@@ -209,12 +208,12 @@ static int plist_free_node(node_t* node)
209 plist_free_data(data); 208 plist_free_data(data);
210 node->data = NULL; 209 node->data = NULL;
211 210
212 node_iterator_t *ni = node_iterator_create(node->children);
213 node_t *ch; 211 node_t *ch;
214 while ((ch = node_iterator_next(ni))) { 212 for (ch = node_first_child(node); ch; ) {
213 node_t *next = node_next_sibling(ch);
215 plist_free_node(ch); 214 plist_free_node(ch);
215 ch = next;
216 } 216 }
217 node_iterator_destroy(ni);
218 217
219 node_destroy(node); 218 node_destroy(node);
220 219
@@ -366,12 +365,10 @@ static void plist_copy_node(node_t *node, void *parent_node_ptr)
366 *(plist_t*)parent_node_ptr = newnode; 365 *(plist_t*)parent_node_ptr = newnode;
367 } 366 }
368 367
369 node_iterator_t *ni = node_iterator_create(node->children);
370 node_t *ch; 368 node_t *ch;
371 while ((ch = node_iterator_next(ni))) { 369 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
372 plist_copy_node(ch, &newnode); 370 plist_copy_node(ch, &newnode);
373 } 371 }
374 node_iterator_destroy(ni);
375} 372}
376 373
377PLIST_API plist_t plist_copy(plist_t node) 374PLIST_API plist_t plist_copy(plist_t node)
diff --git a/src/xplist.c b/src/xplist.c
index 6e64427..29b1284 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -40,7 +40,6 @@
40 40
41#include <node.h> 41#include <node.h>
42#include <node_list.h> 42#include <node_list.h>
43#include <node_iterator.h>
44 43
45#include "plist.h" 44#include "plist.h"
46#include "base64.h" 45#include "base64.h"
@@ -356,12 +355,10 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
356 if (node_data->type == PLIST_DICT) { 355 if (node_data->type == PLIST_DICT) {
357 assert((node->children->count % 2) == 0); 356 assert((node->children->count % 2) == 0);
358 } 357 }
359 node_iterator_t *ni = node_iterator_create(node->children);
360 node_t *ch; 358 node_t *ch;
361 while ((ch = node_iterator_next(ni))) { 359 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
362 node_to_xml(ch, outbuf, depth+1); 360 node_to_xml(ch, outbuf, depth+1);
363 } 361 }
364 node_iterator_destroy(ni);
365 } 362 }
366 363
367 /* fix indent for structured types */ 364 /* fix indent for structured types */