diff options
| author | 2023-02-06 18:28:28 +0100 | |
|---|---|---|
| committer | 2023-02-06 18:28:28 +0100 | |
| commit | d3908006349f38bcfc0151daebd98b6873a2dbfc (patch) | |
| tree | 238072fa5380039ad29af87c0d6e618ab37d4d5b /src/jplist.c | |
| parent | 52826a6c229ed3e353d4dae711a6c52a96d99764 (diff) | |
| download | libplist-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/jplist.c')
| -rw-r--r-- | src/jplist.c | 11 |
1 files changed, 5 insertions, 6 deletions
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 | ||
| 104 | static int node_to_json(node_t* node, bytearray_t **outbuf, uint32_t depth, int prettify) | 103 | static 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 | ||
| 305 | static int node_estimate_size(node_t *node, uint64_t *size, uint32_t depth, int prettify) | 304 | static 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); |
