summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-02-06 18:28:28 +0100
committerGravatar Nikias Bassen2023-02-06 18:28:28 +0100
commitd3908006349f38bcfc0151daebd98b6873a2dbfc (patch)
tree238072fa5380039ad29af87c0d6e618ab37d4d5b /src
parent52826a6c229ed3e353d4dae711a6c52a96d99764 (diff)
downloadlibplist-d3908006349f38bcfc0151daebd98b6873a2dbfc.tar.gz
libplist-d3908006349f38bcfc0151daebd98b6873a2dbfc.tar.bz2
libcnary: Updated typedefs of node_t and node_list_t to contain pointer
This makes the code more readable. Obviously all the code that uses it is also updated.
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c16
-rw-r--r--src/jplist.c11
-rw-r--r--src/oplist.c11
-rw-r--r--src/plist.c82
-rw-r--r--src/xplist.c11
5 files changed, 64 insertions, 67 deletions
diff --git a/src/bplist.c b/src/bplist.c
index c0d0fc8..ff0b399 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -191,7 +191,7 @@ static int uint64_mul_overflow(uint64_t a, uint64_t b, uint64_t *res)
191} 191}
192#endif 192#endif
193 193
194#define NODE_IS_ROOT(x) (((node_t*)(x))->isRoot) 194#define NODE_IS_ROOT(x) (((node_t)(x))->isRoot)
195 195
196struct bplist_data { 196struct bplist_data {
197 const char* data; 197 const char* data;
@@ -936,7 +936,7 @@ struct serialize_s
936 hashtable_t* ref_table; 936 hashtable_t* ref_table;
937}; 937};
938 938
939static void serialize_plist(node_t* node, void* data) 939static void serialize_plist(node_t node, void* data)
940{ 940{
941 uint64_t *index_val = NULL; 941 uint64_t *index_val = NULL;
942 struct serialize_s *ser = (struct serialize_s *) data; 942 struct serialize_s *ser = (struct serialize_s *) data;
@@ -959,7 +959,7 @@ static void serialize_plist(node_t* node, void* data)
959 ptr_array_add(ser->objects, node); 959 ptr_array_add(ser->objects, node);
960 960
961 //now recurse on children 961 //now recurse on children
962 node_t *ch; 962 node_t ch;
963 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 963 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
964 serialize_plist(ch, data); 964 serialize_plist(ch, data);
965 } 965 }
@@ -1111,9 +1111,9 @@ static void write_unicode(bytearray_t * bplist, char *val, uint64_t size)
1111 free(unicodestr); 1111 free(unicodestr);
1112} 1112}
1113 1113
1114static void write_array(bytearray_t * bplist, node_t* node, hashtable_t* ref_table, uint8_t ref_size) 1114static void write_array(bytearray_t * bplist, node_t node, hashtable_t* ref_table, uint8_t ref_size)
1115{ 1115{
1116 node_t* cur = NULL; 1116 node_t cur = NULL;
1117 uint64_t i = 0; 1117 uint64_t i = 0;
1118 1118
1119 uint64_t size = node_n_children(node); 1119 uint64_t size = node_n_children(node);
@@ -1130,9 +1130,9 @@ static void write_array(bytearray_t * bplist, node_t* node, hashtable_t* ref_tab
1130 } 1130 }
1131} 1131}
1132 1132
1133static void write_dict(bytearray_t * bplist, node_t* node, hashtable_t* ref_table, uint8_t ref_size) 1133static void write_dict(bytearray_t * bplist, node_t node, hashtable_t* ref_table, uint8_t ref_size)
1134{ 1134{
1135 node_t* cur = NULL; 1135 node_t cur = NULL;
1136 uint64_t i = 0; 1136 uint64_t i = 0;
1137 1137
1138 uint64_t size = node_n_children(node) / 2; 1138 uint64_t size = node_n_children(node) / 2;
@@ -1235,7 +1235,7 @@ PLIST_API plist_err_t plist_to_bin(plist_t plist, char **plist_bin, uint32_t * l
1235 uint64_t req = 0; 1235 uint64_t req = 0;
1236 for (i = 0; i < num_objects; i++) 1236 for (i = 0; i < num_objects; i++)
1237 { 1237 {
1238 node_t* node = ptr_array_index(objects, i); 1238 node_t node = ptr_array_index(objects, i);
1239 plist_data_t data = plist_get_data(node); 1239 plist_data_t data = plist_get_data(node);
1240 uint64_t size; 1240 uint64_t size;
1241 uint8_t bsize; 1241 uint8_t bsize;
diff --git a/src/jplist.c b/src/jplist.c
index 23fb45b..99a8877 100644
--- a/src/jplist.c
+++ b/src/jplist.c
@@ -34,7 +34,6 @@
34#include <limits.h> 34#include <limits.h>
35 35
36#include <node.h> 36#include <node.h>
37#include <node_list.h>
38 37
39#include "plist.h" 38#include "plist.h"
40#include "strbuf.h" 39#include "strbuf.h"
@@ -101,7 +100,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval)
101 return len; 100 return len;
102} 101}
103 102
104static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int prettify) 103static int node_to_json(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify)
105{ 104{
106 plist_data_t node_data = NULL; 105 plist_data_t node_data = NULL;
107 106
@@ -185,7 +184,7 @@ static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int
185 184
186 case PLIST_ARRAY: { 185 case PLIST_ARRAY: {
187 str_buf_append(*outbuf, "[", 1); 186 str_buf_append(*outbuf, "[", 1);
188 node_t *ch; 187 node_t ch;
189 uint32_t cnt = 0; 188 uint32_t cnt = 0;
190 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 189 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
191 if (cnt > 0) { 190 if (cnt > 0) {
@@ -213,7 +212,7 @@ static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int
213 } break; 212 } break;
214 case PLIST_DICT: { 213 case PLIST_DICT: {
215 str_buf_append(*outbuf, "{", 1); 214 str_buf_append(*outbuf, "{", 1);
216 node_t *ch; 215 node_t ch;
217 uint32_t cnt = 0; 216 uint32_t cnt = 0;
218 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 217 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
219 if (cnt > 0 && cnt % 2 == 0) { 218 if (cnt > 0 && cnt % 2 == 0) {
@@ -302,7 +301,7 @@ static int num_digits_u(uint64_t i)
302 return n; 301 return n;
303} 302}
304 303
305static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int prettify) 304static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify)
306{ 305{
307 plist_data_t data; 306 plist_data_t data;
308 if (!node) { 307 if (!node) {
@@ -310,7 +309,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int
310 } 309 }
311 data = plist_get_data(node); 310 data = plist_get_data(node);
312 if (node->children) { 311 if (node->children) {
313 node_t *ch; 312 node_t ch;
314 unsigned int n_children = node_n_children(node); 313 unsigned int n_children = node_n_children(node);
315 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 314 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
316 int res = node_estimate_size(ch, size, depth + 1, prettify); 315 int res = node_estimate_size(ch, size, depth + 1, prettify);
diff --git a/src/oplist.c b/src/oplist.c
index 420cbd6..287d5a2 100644
--- a/src/oplist.c
+++ b/src/oplist.c
@@ -34,7 +34,6 @@
34#include <limits.h> 34#include <limits.h>
35 35
36#include <node.h> 36#include <node.h>
37#include <node_list.h>
38 37
39#include "plist.h" 38#include "plist.h"
40#include "strbuf.h" 39#include "strbuf.h"
@@ -130,7 +129,7 @@ static int str_needs_quotes(const char* str, size_t len)
130 return 0; 129 return 0;
131} 130}
132 131
133static int node_to_openstep(node_t* node, bytearray_t **outbuf, uint32_t depth, int prettify) 132static int node_to_openstep(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify)
134{ 133{
135 plist_data_t node_data = NULL; 134 plist_data_t node_data = NULL;
136 135
@@ -209,7 +208,7 @@ static int node_to_openstep(node_t* node, bytearray_t **outbuf, uint32_t depth,
209 208
210 case PLIST_ARRAY: { 209 case PLIST_ARRAY: {
211 str_buf_append(*outbuf, "(", 1); 210 str_buf_append(*outbuf, "(", 1);
212 node_t *ch; 211 node_t ch;
213 uint32_t cnt = 0; 212 uint32_t cnt = 0;
214 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 213 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
215 if (cnt > 0) { 214 if (cnt > 0) {
@@ -237,7 +236,7 @@ static int node_to_openstep(node_t* node, bytearray_t **outbuf, uint32_t depth,
237 } break; 236 } break;
238 case PLIST_DICT: { 237 case PLIST_DICT: {
239 str_buf_append(*outbuf, "{", 1); 238 str_buf_append(*outbuf, "{", 1);
240 node_t *ch; 239 node_t ch;
241 uint32_t cnt = 0; 240 uint32_t cnt = 0;
242 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 241 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
243 if (cnt > 0 && cnt % 2 == 0) { 242 if (cnt > 0 && cnt % 2 == 0) {
@@ -346,7 +345,7 @@ static int num_digits_u(uint64_t i)
346 return n; 345 return n;
347} 346}
348 347
349static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int prettify) 348static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify)
350{ 349{
351 plist_data_t data; 350 plist_data_t data;
352 if (!node) { 351 if (!node) {
@@ -354,7 +353,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int
354 } 353 }
355 data = plist_get_data(node); 354 data = plist_get_data(node);
356 if (node->children) { 355 if (node->children) {
357 node_t *ch; 356 node_t ch;
358 unsigned int n_children = node_n_children(node); 357 unsigned int n_children = node_n_children(node);
359 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 358 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
360 int res = node_estimate_size(ch, size, depth + 1, prettify); 359 int res = node_estimate_size(ch, size, depth + 1, prettify);
diff --git a/src/plist.c b/src/plist.c
index 0fcd926..689fc79 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -266,7 +266,7 @@ plist_data_t plist_get_data(plist_t node)
266{ 266{
267 if (!node) 267 if (!node)
268 return NULL; 268 return NULL;
269 return ((node_t*)node)->data; 269 return ((node_t)node)->data;
270} 270}
271 271
272plist_data_t plist_new_plist_data(void) 272plist_data_t plist_new_plist_data(void)
@@ -326,7 +326,7 @@ void plist_free_data(plist_data_t data)
326 } 326 }
327} 327}
328 328
329static int plist_free_node(node_t* node) 329static int plist_free_node(node_t node)
330{ 330{
331 plist_data_t data = NULL; 331 plist_data_t data = NULL;
332 int node_index = node_detach(node->parent, node); 332 int node_index = node_detach(node->parent, node);
@@ -334,9 +334,9 @@ static int plist_free_node(node_t* node)
334 plist_free_data(data); 334 plist_free_data(data);
335 node->data = NULL; 335 node->data = NULL;
336 336
337 node_t *ch; 337 node_t ch;
338 for (ch = node_first_child(node); ch; ) { 338 for (ch = node_first_child(node); ch; ) {
339 node_t *next = node_next_sibling(ch); 339 node_t next = node_next_sibling(ch);
340 plist_free_node(ch); 340 plist_free_node(ch);
341 ch = next; 341 ch = next;
342 } 342 }
@@ -468,7 +468,7 @@ PLIST_API void plist_mem_free(void* ptr)
468 } 468 }
469} 469}
470 470
471static plist_t plist_copy_node(node_t *node) 471static plist_t plist_copy_node(node_t node)
472{ 472{
473 plist_type node_type = PLIST_NONE; 473 plist_type node_type = PLIST_NONE;
474 plist_t newnode = NULL; 474 plist_t newnode = NULL;
@@ -509,7 +509,7 @@ static plist_t plist_copy_node(node_t *node)
509 } 509 }
510 newnode = plist_new_node(newdata); 510 newnode = plist_new_node(newdata);
511 511
512 node_t *ch; 512 node_t ch;
513 unsigned int node_index = 0; 513 unsigned int node_index = 0;
514 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 514 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
515 /* copy child node */ 515 /* copy child node */
@@ -525,7 +525,7 @@ static plist_t plist_copy_node(node_t *node)
525 break; 525 break;
526 case PLIST_DICT: 526 case PLIST_DICT:
527 if (newdata->hashtable && (node_index % 2 != 0)) { 527 if (newdata->hashtable && (node_index % 2 != 0)) {
528 hash_table_insert((hashtable_t*)newdata->hashtable, (node_prev_sibling((node_t*)newch))->data, newch); 528 hash_table_insert((hashtable_t*)newdata->hashtable, (node_prev_sibling((node_t)newch))->data, newch);
529 } 529 }
530 break; 530 break;
531 default: 531 default:
@@ -556,7 +556,7 @@ PLIST_API plist_t plist_array_get_item(plist_t node, uint32_t n)
556 plist_t ret = NULL; 556 plist_t ret = NULL;
557 if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX) 557 if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX)
558 { 558 {
559 ptrarray_t *pa = ((plist_data_t)((node_t*)node)->data)->hashtable; 559 ptrarray_t *pa = ((plist_data_t)((node_t)node)->data)->hashtable;
560 if (pa) { 560 if (pa) {
561 ret = (plist_t)ptr_array_index(pa, n); 561 ret = (plist_t)ptr_array_index(pa, n);
562 } else { 562 } else {
@@ -578,12 +578,12 @@ PLIST_API uint32_t plist_array_get_item_index(plist_t node)
578 578
579static void _plist_array_post_insert(plist_t node, plist_t item, long n) 579static void _plist_array_post_insert(plist_t node, plist_t item, long n)
580{ 580{
581 ptrarray_t *pa = ((plist_data_t)((node_t*)node)->data)->hashtable; 581 ptrarray_t *pa = ((plist_data_t)((node_t)node)->data)->hashtable;
582 if (pa) { 582 if (pa) {
583 /* store pointer to item in array */ 583 /* store pointer to item in array */
584 ptr_array_insert(pa, item, n); 584 ptr_array_insert(pa, item, n);
585 } else { 585 } else {
586 if (((node_t*)node)->count > 100) { 586 if (((node_t)node)->count > 100) {
587 /* make new lookup array */ 587 /* make new lookup array */
588 pa = ptr_array_new(128); 588 pa = ptr_array_new(128);
589 plist_t current = NULL; 589 plist_t current = NULL;
@@ -593,7 +593,7 @@ static void _plist_array_post_insert(plist_t node, plist_t item, long n)
593 { 593 {
594 ptr_array_add(pa, current); 594 ptr_array_add(pa, current);
595 } 595 }
596 ((plist_data_t)((node_t*)node)->data)->hashtable = pa; 596 ((plist_data_t)((node_t)node)->data)->hashtable = pa;
597 } 597 }
598 } 598 }
599} 599}
@@ -611,7 +611,7 @@ PLIST_API void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
611 return; 611 return;
612 } 612 }
613 node_insert(node, idx, item); 613 node_insert(node, idx, item);
614 ptrarray_t* pa = ((plist_data_t)((node_t*)node)->data)->hashtable; 614 ptrarray_t* pa = ((plist_data_t)((node_t)node)->data)->hashtable;
615 if (pa) { 615 if (pa) {
616 ptr_array_set(pa, item, idx); 616 ptr_array_set(pa, item, idx);
617 } 617 }
@@ -644,7 +644,7 @@ PLIST_API void plist_array_remove_item(plist_t node, uint32_t n)
644 plist_t old_item = plist_array_get_item(node, n); 644 plist_t old_item = plist_array_get_item(node, n);
645 if (old_item) 645 if (old_item)
646 { 646 {
647 ptrarray_t* pa = ((plist_data_t)((node_t*)node)->data)->hashtable; 647 ptrarray_t* pa = ((plist_data_t)((node_t)node)->data)->hashtable;
648 if (pa) { 648 if (pa) {
649 ptr_array_remove(pa, n); 649 ptr_array_remove(pa, n);
650 } 650 }
@@ -660,7 +660,7 @@ PLIST_API void plist_array_item_remove(plist_t node)
660 { 660 {
661 int n = node_child_position(father, node); 661 int n = node_child_position(father, node);
662 if (n < 0) return; 662 if (n < 0) return;
663 ptrarray_t* pa = ((plist_data_t)((node_t*)father)->data)->hashtable; 663 ptrarray_t* pa = ((plist_data_t)((node_t)father)->data)->hashtable;
664 if (pa) { 664 if (pa) {
665 ptr_array_remove(pa, n); 665 ptr_array_remove(pa, n);
666 } 666 }
@@ -672,14 +672,14 @@ PLIST_API void plist_array_new_iter(plist_t node, plist_array_iter *iter)
672{ 672{
673 if (iter) 673 if (iter)
674 { 674 {
675 *iter = malloc(sizeof(node_t*)); 675 *iter = malloc(sizeof(node_t));
676 *((node_t**)(*iter)) = node_first_child(node); 676 *((node_t*)(*iter)) = node_first_child(node);
677 } 677 }
678} 678}
679 679
680PLIST_API void plist_array_next_item(plist_t node, plist_array_iter iter, plist_t *item) 680PLIST_API void plist_array_next_item(plist_t node, plist_array_iter iter, plist_t *item)
681{ 681{
682 node_t** iter_node = (node_t**)iter; 682 node_t* iter_node = (node_t*)iter;
683 683
684 if (item) 684 if (item)
685 { 685 {
@@ -710,14 +710,14 @@ PLIST_API void plist_dict_new_iter(plist_t node, plist_dict_iter *iter)
710{ 710{
711 if (iter) 711 if (iter)
712 { 712 {
713 *iter = malloc(sizeof(node_t*)); 713 *iter = malloc(sizeof(node_t));
714 *((node_t**)(*iter)) = node_first_child(node); 714 *((node_t*)(*iter)) = node_first_child(node);
715 } 715 }
716} 716}
717 717
718PLIST_API void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val) 718PLIST_API void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val)
719{ 719{
720 node_t** iter_node = (node_t**)iter; 720 node_t* iter_node = (node_t*)iter;
721 721
722 if (key) 722 if (key)
723 { 723 {
@@ -799,7 +799,7 @@ PLIST_API plist_t plist_dict_get_item(plist_t node, const char* key)
799PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item) 799PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item)
800{ 800{
801 if (node && PLIST_DICT == plist_get_node_type(node)) { 801 if (node && PLIST_DICT == plist_get_node_type(node)) {
802 node_t* old_item = plist_dict_get_item(node, key); 802 node_t old_item = plist_dict_get_item(node, key);
803 plist_t key_node = NULL; 803 plist_t key_node = NULL;
804 if (old_item) { 804 if (old_item) {
805 int idx = plist_free_node(old_item); 805 int idx = plist_free_node(old_item);
@@ -815,12 +815,12 @@ PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item)
815 node_attach(node, item); 815 node_attach(node, item);
816 } 816 }
817 817
818 hashtable_t *ht = ((plist_data_t)((node_t*)node)->data)->hashtable; 818 hashtable_t *ht = ((plist_data_t)((node_t)node)->data)->hashtable;
819 if (ht) { 819 if (ht) {
820 /* store pointer to item in hash table */ 820 /* store pointer to item in hash table */
821 hash_table_insert(ht, (plist_data_t)((node_t*)key_node)->data, item); 821 hash_table_insert(ht, (plist_data_t)((node_t)key_node)->data, item);
822 } else { 822 } else {
823 if (((node_t*)node)->count > 500) { 823 if (((node_t)node)->count > 500) {
824 /* make new hash table */ 824 /* make new hash table */
825 ht = hash_table_new(dict_key_hash, dict_key_compare, NULL); 825 ht = hash_table_new(dict_key_hash, dict_key_compare, NULL);
826 /* calculate the hashes for all entries we have so far */ 826 /* calculate the hashes for all entries we have so far */
@@ -829,9 +829,9 @@ PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item)
829 ht && current; 829 ht && current;
830 current = (plist_t)node_next_sibling(node_next_sibling(current))) 830 current = (plist_t)node_next_sibling(node_next_sibling(current)))
831 { 831 {
832 hash_table_insert(ht, ((node_t*)current)->data, node_next_sibling(current)); 832 hash_table_insert(ht, ((node_t)current)->data, node_next_sibling(current));
833 } 833 }
834 ((plist_data_t)((node_t*)node)->data)->hashtable = ht; 834 ((plist_data_t)((node_t)node)->data)->hashtable = ht;
835 } 835 }
836 } 836 }
837 } 837 }
@@ -850,9 +850,9 @@ PLIST_API void plist_dict_remove_item(plist_t node, const char* key)
850 if (old_item) 850 if (old_item)
851 { 851 {
852 plist_t key_node = node_prev_sibling(old_item); 852 plist_t key_node = node_prev_sibling(old_item);
853 hashtable_t* ht = ((plist_data_t)((node_t*)node)->data)->hashtable; 853 hashtable_t* ht = ((plist_data_t)((node_t)node)->data)->hashtable;
854 if (ht) { 854 if (ht) {
855 hash_table_remove(ht, ((node_t*)key_node)->data); 855 hash_table_remove(ht, ((node_t)key_node)->data);
856 } 856 }
857 plist_free(key_node); 857 plist_free(key_node);
858 plist_free(old_item); 858 plist_free(old_item);
@@ -961,7 +961,7 @@ static void plist_get_type_and_value(plist_t node, plist_type * type, void *valu
961 961
962PLIST_API plist_t plist_get_parent(plist_t node) 962PLIST_API plist_t plist_get_parent(plist_t node)
963{ 963{
964 return node ? (plist_t) ((node_t*) node)->parent : NULL; 964 return node ? (plist_t) ((node_t) node)->parent : NULL;
965} 965}
966 966
967PLIST_API plist_type plist_get_node_type(plist_t node) 967PLIST_API plist_type plist_get_node_type(plist_t node)
@@ -1119,7 +1119,7 @@ int plist_data_compare(const void *a, const void *b)
1119 if (!a || !b) 1119 if (!a || !b)
1120 return FALSE; 1120 return FALSE;
1121 1121
1122 if (!((node_t*) a)->data || !((node_t*) b)->data) 1122 if (!((node_t) a)->data || !((node_t) b)->data)
1123 return FALSE; 1123 return FALSE;
1124 1124
1125 val_a = plist_get_data((plist_t) a); 1125 val_a = plist_get_data((plist_t) a);
@@ -1509,8 +1509,8 @@ PLIST_API void plist_sort(plist_t plist)
1509 plist_sort(plist_array_get_item(plist, i)); 1509 plist_sort(plist_array_get_item(plist, i));
1510 } 1510 }
1511 } else if (PLIST_IS_DICT(plist)) { 1511 } else if (PLIST_IS_DICT(plist)) {
1512 node_t *node = (node_t*)plist; 1512 node_t node = (node_t)plist;
1513 node_t *ch; 1513 node_t ch;
1514 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 1514 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
1515 ch = node_next_sibling(ch); 1515 ch = node_next_sibling(ch);
1516 plist_sort((plist_t)ch); 1516 plist_sort((plist_t)ch);
@@ -1521,22 +1521,22 @@ PLIST_API void plist_sort(plist_t plist)
1521 int swapped = 0; 1521 int swapped = 0;
1522 do { 1522 do {
1523 swapped = 0; 1523 swapped = 0;
1524 node_t *lptr = NULL; 1524 node_t lptr = NULL;
1525 node_t *cur_key = node_first_child((node_t*)plist); 1525 node_t cur_key = node_first_child((node_t)plist);
1526 1526
1527 while (NEXT_KEY(cur_key) != lptr) { 1527 while (NEXT_KEY(cur_key) != lptr) {
1528 node_t *next_key = NEXT_KEY(cur_key); 1528 node_t next_key = NEXT_KEY(cur_key);
1529 if (strcmp(KEY_STRVAL(cur_key), KEY_STRVAL(next_key)) > 0) { 1529 if (strcmp(KEY_STRVAL(cur_key), KEY_STRVAL(next_key)) > 0) {
1530 node_t *cur_val = cur_key->next; 1530 node_t cur_val = cur_key->next;
1531 node_t *next_val = next_key->next; 1531 node_t next_val = next_key->next;
1532 // we need to swap 2 consecutive nodes with the 2 after them 1532 // we need to swap 2 consecutive nodes with the 2 after them
1533 // a -> b -> [c] -> [d] -> [e] -> [f] -> g -> h 1533 // a -> b -> [c] -> [d] -> [e] -> [f] -> g -> h
1534 // cur next 1534 // cur next
1535 // swapped: 1535 // swapped:
1536 // a -> b -> [e] -> [f] -> [c] -> [d] -> g -> h 1536 // a -> b -> [e] -> [f] -> [c] -> [d] -> g -> h
1537 // next cur 1537 // next cur
1538 node_t *tmp_prev = cur_key->prev; 1538 node_t tmp_prev = cur_key->prev;
1539 node_t *tmp_next = next_val->next; 1539 node_t tmp_next = next_val->next;
1540 cur_key->prev = next_val; 1540 cur_key->prev = next_val;
1541 cur_val->next = tmp_next; 1541 cur_val->next = tmp_next;
1542 next_val->next = cur_key; 1542 next_val->next = cur_key;
@@ -1544,12 +1544,12 @@ PLIST_API void plist_sort(plist_t plist)
1544 if (tmp_prev) { 1544 if (tmp_prev) {
1545 tmp_prev->next = next_key; 1545 tmp_prev->next = next_key;
1546 } else { 1546 } else {
1547 ((node_t*)plist)->children->begin = next_key; 1547 ((node_t)plist)->children->begin = next_key;
1548 } 1548 }
1549 if (tmp_next) { 1549 if (tmp_next) {
1550 tmp_next->prev = cur_val; 1550 tmp_next->prev = cur_val;
1551 } else { 1551 } else {
1552 ((node_t*)plist)->children->end = cur_val; 1552 ((node_t)plist)->children->end = cur_val;
1553 } 1553 }
1554 cur_key = next_key; 1554 cur_key = next_key;
1555 swapped = 1; 1555 swapped = 1;
diff --git a/src/xplist.c b/src/xplist.c
index 0a6be57..1abc46d 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -41,7 +41,6 @@
41#include <limits.h> 41#include <limits.h>
42 42
43#include <node.h> 43#include <node.h>
44#include <node_list.h>
45 44
46#include "plist.h" 45#include "plist.h"
47#include "base64.h" 46#include "base64.h"
@@ -127,7 +126,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval)
127 return len; 126 return len;
128} 127}
129 128
130static int node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth) 129static int node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth)
131{ 130{
132 plist_data_t node_data = NULL; 131 plist_data_t node_data = NULL;
133 132
@@ -358,7 +357,7 @@ static int node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
358 if (node_data->type == PLIST_DICT && node->children) { 357 if (node_data->type == PLIST_DICT && node->children) {
359 assert((node->children->count % 2) == 0); 358 assert((node->children->count % 2) == 0);
360 } 359 }
361 node_t *ch; 360 node_t ch;
362 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 361 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
363 int res = node_to_xml(ch, outbuf, depth+1); 362 int res = node_to_xml(ch, outbuf, depth+1);
364 if (res < 0) return res; 363 if (res < 0) return res;
@@ -438,7 +437,7 @@ static int num_digits_u(uint64_t i)
438 return n; 437 return n;
439} 438}
440 439
441static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth) 440static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth)
442{ 441{
443 plist_data_t data; 442 plist_data_t data;
444 if (!node) { 443 if (!node) {
@@ -446,7 +445,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth)
446 } 445 }
447 data = plist_get_data(node); 446 data = plist_get_data(node);
448 if (node->children) { 447 if (node->children) {
449 node_t *ch; 448 node_t ch;
450 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) { 449 for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
451 node_estimate_size(ch, size, depth + 1); 450 node_estimate_size(ch, size, depth + 1);
452 } 451 }
@@ -1413,7 +1412,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
1413 node_path = node_path->prev; 1412 node_path = node_path->prev;
1414 free(path_item); 1413 free(path_item);
1415 1414
1416 parent = ((node_t*)parent)->parent; 1415 parent = ((node_t)parent)->parent;
1417 if (!parent) { 1416 if (!parent) {
1418 goto err_out; 1417 goto err_out;
1419 } 1418 }