summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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)
}
#endif
-#define NODE_IS_ROOT(x) (((node_t*)(x))->isRoot)
+#define NODE_IS_ROOT(x) (((node_t)(x))->isRoot)
struct bplist_data {
const char* data;
@@ -936,7 +936,7 @@ struct serialize_s
hashtable_t* ref_table;
};
-static void serialize_plist(node_t* node, void* data)
+static void serialize_plist(node_t node, void* data)
{
uint64_t *index_val = NULL;
struct serialize_s *ser = (struct serialize_s *) data;
@@ -959,7 +959,7 @@ static void serialize_plist(node_t* node, void* data)
ptr_array_add(ser->objects, node);
//now recurse on children
- node_t *ch;
+ node_t ch;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
serialize_plist(ch, data);
}
@@ -1111,9 +1111,9 @@ static void write_unicode(bytearray_t * bplist, char *val, uint64_t size)
free(unicodestr);
}
-static void write_array(bytearray_t * bplist, node_t* node, hashtable_t* ref_table, uint8_t ref_size)
+static void write_array(bytearray_t * bplist, node_t node, hashtable_t* ref_table, uint8_t ref_size)
{
- node_t* cur = NULL;
+ node_t cur = NULL;
uint64_t i = 0;
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
}
}
-static void write_dict(bytearray_t * bplist, node_t* node, hashtable_t* ref_table, uint8_t ref_size)
+static void write_dict(bytearray_t * bplist, node_t node, hashtable_t* ref_table, uint8_t ref_size)
{
- node_t* cur = NULL;
+ node_t cur = NULL;
uint64_t i = 0;
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
uint64_t req = 0;
for (i = 0; i < num_objects; i++)
{
- node_t* node = ptr_array_index(objects, i);
+ node_t node = ptr_array_index(objects, i);
plist_data_t data = plist_get_data(node);
uint64_t size;
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 @@
#include <limits.h>
#include <node.h>
-#include <node_list.h>
#include "plist.h"
#include "strbuf.h"
@@ -101,7 +100,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval)
return len;
}
-static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int prettify)
+static int node_to_json(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify)
{
plist_data_t node_data = NULL;
@@ -185,7 +184,7 @@ static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int
case PLIST_ARRAY: {
str_buf_append(*outbuf, "[", 1);
- node_t *ch;
+ node_t ch;
uint32_t cnt = 0;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
if (cnt > 0) {
@@ -213,7 +212,7 @@ static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int
} break;
case PLIST_DICT: {
str_buf_append(*outbuf, "{", 1);
- node_t *ch;
+ node_t ch;
uint32_t cnt = 0;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
if (cnt > 0 && cnt % 2 == 0) {
@@ -302,7 +301,7 @@ static int num_digits_u(uint64_t i)
return n;
}
-static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int prettify)
+static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify)
{
plist_data_t data;
if (!node) {
@@ -310,7 +309,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int
}
data = plist_get_data(node);
if (node->children) {
- node_t *ch;
+ node_t ch;
unsigned int n_children = node_n_children(node);
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
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 @@
#include <limits.h>
#include <node.h>
-#include <node_list.h>
#include "plist.h"
#include "strbuf.h"
@@ -130,7 +129,7 @@ static int str_needs_quotes(const char* str, size_t len)
return 0;
}
-static int node_to_openstep(node_t* node, bytearray_t **outbuf, uint32_t depth, int prettify)
+static int node_to_openstep(node_t node, bytearray_t **outbuf, uint32_t depth, int prettify)
{
plist_data_t node_data = NULL;
@@ -209,7 +208,7 @@ static int node_to_openstep(node_t* node, bytearray_t **outbuf, uint32_t depth,
case PLIST_ARRAY: {
str_buf_append(*outbuf, "(", 1);
- node_t *ch;
+ node_t ch;
uint32_t cnt = 0;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
if (cnt > 0) {
@@ -237,7 +236,7 @@ static int node_to_openstep(node_t* node, bytearray_t **outbuf, uint32_t depth,
} break;
case PLIST_DICT: {
str_buf_append(*outbuf, "{", 1);
- node_t *ch;
+ node_t ch;
uint32_t cnt = 0;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
if (cnt > 0 && cnt % 2 == 0) {
@@ -346,7 +345,7 @@ static int num_digits_u(uint64_t i)
return n;
}
-static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int prettify)
+static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth, int prettify)
{
plist_data_t data;
if (!node) {
@@ -354,7 +353,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int
}
data = plist_get_data(node);
if (node->children) {
- node_t *ch;
+ node_t ch;
unsigned int n_children = node_n_children(node);
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
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)
{
if (!node)
return NULL;
- return ((node_t*)node)->data;
+ return ((node_t)node)->data;
}
plist_data_t plist_new_plist_data(void)
@@ -326,7 +326,7 @@ void plist_free_data(plist_data_t data)
}
}
-static int plist_free_node(node_t* node)
+static int plist_free_node(node_t node)
{
plist_data_t data = NULL;
int node_index = node_detach(node->parent, node);
@@ -334,9 +334,9 @@ static int plist_free_node(node_t* node)
plist_free_data(data);
node->data = NULL;
- node_t *ch;
+ node_t ch;
for (ch = node_first_child(node); ch; ) {
- node_t *next = node_next_sibling(ch);
+ node_t next = node_next_sibling(ch);
plist_free_node(ch);
ch = next;
}
@@ -468,7 +468,7 @@ PLIST_API void plist_mem_free(void* ptr)
}
}
-static plist_t plist_copy_node(node_t *node)
+static plist_t plist_copy_node(node_t node)
{
plist_type node_type = PLIST_NONE;
plist_t newnode = NULL;
@@ -509,7 +509,7 @@ static plist_t plist_copy_node(node_t *node)
}
newnode = plist_new_node(newdata);
- node_t *ch;
+ node_t ch;
unsigned int node_index = 0;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
/* copy child node */
@@ -525,7 +525,7 @@ static plist_t plist_copy_node(node_t *node)
break;
case PLIST_DICT:
if (newdata->hashtable && (node_index % 2 != 0)) {
- hash_table_insert((hashtable_t*)newdata->hashtable, (node_prev_sibling((node_t*)newch))->data, newch);
+ hash_table_insert((hashtable_t*)newdata->hashtable, (node_prev_sibling((node_t)newch))->data, newch);
}
break;
default:
@@ -556,7 +556,7 @@ PLIST_API plist_t plist_array_get_item(plist_t node, uint32_t n)
plist_t ret = NULL;
if (node && PLIST_ARRAY == plist_get_node_type(node) && n < INT_MAX)
{
- ptrarray_t *pa = ((plist_data_t)((node_t*)node)->data)->hashtable;
+ ptrarray_t *pa = ((plist_data_t)((node_t)node)->data)->hashtable;
if (pa) {
ret = (plist_t)ptr_array_index(pa, n);
} else {
@@ -578,12 +578,12 @@ PLIST_API uint32_t plist_array_get_item_index(plist_t node)
static void _plist_array_post_insert(plist_t node, plist_t item, long n)
{
- ptrarray_t *pa = ((plist_data_t)((node_t*)node)->data)->hashtable;
+ ptrarray_t *pa = ((plist_data_t)((node_t)node)->data)->hashtable;
if (pa) {
/* store pointer to item in array */
ptr_array_insert(pa, item, n);
} else {
- if (((node_t*)node)->count > 100) {
+ if (((node_t)node)->count > 100) {
/* make new lookup array */
pa = ptr_array_new(128);
plist_t current = NULL;
@@ -593,7 +593,7 @@ static void _plist_array_post_insert(plist_t node, plist_t item, long n)
{
ptr_array_add(pa, current);
}
- ((plist_data_t)((node_t*)node)->data)->hashtable = pa;
+ ((plist_data_t)((node_t)node)->data)->hashtable = pa;
}
}
}
@@ -611,7 +611,7 @@ PLIST_API void plist_array_set_item(plist_t node, plist_t item, uint32_t n)
return;
}
node_insert(node, idx, item);
- ptrarray_t* pa = ((plist_data_t)((node_t*)node)->data)->hashtable;
+ ptrarray_t* pa = ((plist_data_t)((node_t)node)->data)->hashtable;
if (pa) {
ptr_array_set(pa, item, idx);
}
@@ -644,7 +644,7 @@ PLIST_API void plist_array_remove_item(plist_t node, uint32_t n)
plist_t old_item = plist_array_get_item(node, n);
if (old_item)
{
- ptrarray_t* pa = ((plist_data_t)((node_t*)node)->data)->hashtable;
+ ptrarray_t* pa = ((plist_data_t)((node_t)node)->data)->hashtable;
if (pa) {
ptr_array_remove(pa, n);
}
@@ -660,7 +660,7 @@ PLIST_API void plist_array_item_remove(plist_t node)
{
int n = node_child_position(father, node);
if (n < 0) return;
- ptrarray_t* pa = ((plist_data_t)((node_t*)father)->data)->hashtable;
+ ptrarray_t* pa = ((plist_data_t)((node_t)father)->data)->hashtable;
if (pa) {
ptr_array_remove(pa, n);
}
@@ -672,14 +672,14 @@ PLIST_API void plist_array_new_iter(plist_t node, plist_array_iter *iter)
{
if (iter)
{
- *iter = malloc(sizeof(node_t*));
- *((node_t**)(*iter)) = node_first_child(node);
+ *iter = malloc(sizeof(node_t));
+ *((node_t*)(*iter)) = node_first_child(node);
}
}
PLIST_API void plist_array_next_item(plist_t node, plist_array_iter iter, plist_t *item)
{
- node_t** iter_node = (node_t**)iter;
+ node_t* iter_node = (node_t*)iter;
if (item)
{
@@ -710,14 +710,14 @@ PLIST_API void plist_dict_new_iter(plist_t node, plist_dict_iter *iter)
{
if (iter)
{
- *iter = malloc(sizeof(node_t*));
- *((node_t**)(*iter)) = node_first_child(node);
+ *iter = malloc(sizeof(node_t));
+ *((node_t*)(*iter)) = node_first_child(node);
}
}
PLIST_API void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val)
{
- node_t** iter_node = (node_t**)iter;
+ node_t* iter_node = (node_t*)iter;
if (key)
{
@@ -799,7 +799,7 @@ PLIST_API plist_t plist_dict_get_item(plist_t node, const char* key)
PLIST_API void plist_dict_set_item(plist_t node, const char* key, plist_t item)
{
if (node && PLIST_DICT == plist_get_node_type(node)) {
- node_t* old_item = plist_dict_get_item(node, key);
+ node_t old_item = plist_dict_get_item(node, key);
plist_t key_node = NULL;
if (old_item) {
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)
node_attach(node, item);
}
- hashtable_t *ht = ((plist_data_t)((node_t*)node)->data)->hashtable;
+ hashtable_t *ht = ((plist_data_t)((node_t)node)->data)->hashtable;
if (ht) {
/* store pointer to item in hash table */
- hash_table_insert(ht, (plist_data_t)((node_t*)key_node)->data, item);
+ hash_table_insert(ht, (plist_data_t)((node_t)key_node)->data, item);
} else {
- if (((node_t*)node)->count > 500) {
+ if (((node_t)node)->count > 500) {
/* make new hash table */
ht = hash_table_new(dict_key_hash, dict_key_compare, NULL);
/* 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)
ht && current;
current = (plist_t)node_next_sibling(node_next_sibling(current)))
{
- hash_table_insert(ht, ((node_t*)current)->data, node_next_sibling(current));
+ hash_table_insert(ht, ((node_t)current)->data, node_next_sibling(current));
}
- ((plist_data_t)((node_t*)node)->data)->hashtable = ht;
+ ((plist_data_t)((node_t)node)->data)->hashtable = ht;
}
}
}
@@ -850,9 +850,9 @@ PLIST_API void plist_dict_remove_item(plist_t node, const char* key)
if (old_item)
{
plist_t key_node = node_prev_sibling(old_item);
- hashtable_t* ht = ((plist_data_t)((node_t*)node)->data)->hashtable;
+ hashtable_t* ht = ((plist_data_t)((node_t)node)->data)->hashtable;
if (ht) {
- hash_table_remove(ht, ((node_t*)key_node)->data);
+ hash_table_remove(ht, ((node_t)key_node)->data);
}
plist_free(key_node);
plist_free(old_item);
@@ -961,7 +961,7 @@ static void plist_get_type_and_value(plist_t node, plist_type * type, void *valu
PLIST_API plist_t plist_get_parent(plist_t node)
{
- return node ? (plist_t) ((node_t*) node)->parent : NULL;
+ return node ? (plist_t) ((node_t) node)->parent : NULL;
}
PLIST_API plist_type plist_get_node_type(plist_t node)
@@ -1119,7 +1119,7 @@ int plist_data_compare(const void *a, const void *b)
if (!a || !b)
return FALSE;
- if (!((node_t*) a)->data || !((node_t*) b)->data)
+ if (!((node_t) a)->data || !((node_t) b)->data)
return FALSE;
val_a = plist_get_data((plist_t) a);
@@ -1509,8 +1509,8 @@ PLIST_API void plist_sort(plist_t plist)
plist_sort(plist_array_get_item(plist, i));
}
} else if (PLIST_IS_DICT(plist)) {
- node_t *node = (node_t*)plist;
- node_t *ch;
+ node_t node = (node_t)plist;
+ node_t ch;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
ch = node_next_sibling(ch);
plist_sort((plist_t)ch);
@@ -1521,22 +1521,22 @@ PLIST_API void plist_sort(plist_t plist)
int swapped = 0;
do {
swapped = 0;
- node_t *lptr = NULL;
- node_t *cur_key = node_first_child((node_t*)plist);
+ node_t lptr = NULL;
+ node_t cur_key = node_first_child((node_t)plist);
while (NEXT_KEY(cur_key) != lptr) {
- node_t *next_key = NEXT_KEY(cur_key);
+ node_t next_key = NEXT_KEY(cur_key);
if (strcmp(KEY_STRVAL(cur_key), KEY_STRVAL(next_key)) > 0) {
- node_t *cur_val = cur_key->next;
- node_t *next_val = next_key->next;
+ node_t cur_val = cur_key->next;
+ node_t next_val = next_key->next;
// we need to swap 2 consecutive nodes with the 2 after them
// a -> b -> [c] -> [d] -> [e] -> [f] -> g -> h
// cur next
// swapped:
// a -> b -> [e] -> [f] -> [c] -> [d] -> g -> h
// next cur
- node_t *tmp_prev = cur_key->prev;
- node_t *tmp_next = next_val->next;
+ node_t tmp_prev = cur_key->prev;
+ node_t tmp_next = next_val->next;
cur_key->prev = next_val;
cur_val->next = tmp_next;
next_val->next = cur_key;
@@ -1544,12 +1544,12 @@ PLIST_API void plist_sort(plist_t plist)
if (tmp_prev) {
tmp_prev->next = next_key;
} else {
- ((node_t*)plist)->children->begin = next_key;
+ ((node_t)plist)->children->begin = next_key;
}
if (tmp_next) {
tmp_next->prev = cur_val;
} else {
- ((node_t*)plist)->children->end = cur_val;
+ ((node_t)plist)->children->end = cur_val;
}
cur_key = next_key;
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 @@
#include <limits.h>
#include <node.h>
-#include <node_list.h>
#include "plist.h"
#include "base64.h"
@@ -127,7 +126,7 @@ static size_t dtostr(char *buf, size_t bufsize, double realval)
return len;
}
-static int node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
+static int node_to_xml(node_t node, bytearray_t **outbuf, uint32_t depth)
{
plist_data_t node_data = NULL;
@@ -358,7 +357,7 @@ static int node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
if (node_data->type == PLIST_DICT && node->children) {
assert((node->children->count % 2) == 0);
}
- node_t *ch;
+ node_t ch;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
int res = node_to_xml(ch, outbuf, depth+1);
if (res < 0) return res;
@@ -438,7 +437,7 @@ static int num_digits_u(uint64_t i)
return n;
}
-static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth)
+static int node_estimate_size(node_t node, uint64_t *size, uint32_t depth)
{
plist_data_t data;
if (!node) {
@@ -446,7 +445,7 @@ static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth)
}
data = plist_get_data(node);
if (node->children) {
- node_t *ch;
+ node_t ch;
for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
node_estimate_size(ch, size, depth + 1);
}
@@ -1413,7 +1412,7 @@ static int node_from_xml(parse_ctx ctx, plist_t *plist)
node_path = node_path->prev;
free(path_item);
- parent = ((node_t*)parent)->parent;
+ parent = ((node_t)parent)->parent;
if (!parent) {
goto err_out;
}