diff options
| author | 2009-01-29 18:54:18 +0100 | |
|---|---|---|
| committer | 2009-01-29 18:54:18 +0100 | |
| commit | 6d2cd169b0a73915964076a9dc653011e07875d3 (patch) | |
| tree | 7674a901cc02ab2cc390b6264ce1c42ce87465fc | |
| parent | ecfe5f4ece77491d764d570aad02fd422da5338c (diff) | |
| download | libplist-6d2cd169b0a73915964076a9dc653011e07875d3.tar.gz libplist-6d2cd169b0a73915964076a9dc653011e07875d3.tar.bz2 | |
Make pointer argument in API const when possible.
| -rw-r--r-- | include/plist/plist.h | 14 | ||||
| -rw-r--r-- | src/plist.c | 16 |
2 files changed, 15 insertions, 15 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h index b666d2f..c5af845 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h | |||
| @@ -50,17 +50,17 @@ typedef enum { | |||
| 50 | plist_t plist_new_dict(); | 50 | plist_t plist_new_dict(); |
| 51 | plist_t plist_new_array(); | 51 | plist_t plist_new_array(); |
| 52 | //Plist edition, create a new root if node is NULL | 52 | //Plist edition, create a new root if node is NULL |
| 53 | plist_t plist_add_sub_element( plist_t node, plist_type type, void* value, uint64_t length); | 53 | plist_t plist_add_sub_element( plist_t node, plist_type type, const void* value, uint64_t length); |
| 54 | 54 | ||
| 55 | //Plist edition, only work for dict and array node | 55 | //Plist edition, only work for dict and array node |
| 56 | void plist_add_sub_node(plist_t node, plist_t subnode); | 56 | void plist_add_sub_node(plist_t node, plist_t subnode); |
| 57 | 57 | ||
| 58 | void plist_add_sub_key_el(plist_t node, char* val); | 58 | void plist_add_sub_key_el(plist_t node, const char* val); |
| 59 | void plist_add_sub_string_el(plist_t node, char* val); | 59 | void plist_add_sub_string_el(plist_t node, const char* val); |
| 60 | void plist_add_sub_bool_el(plist_t node, uint8_t val); | 60 | void plist_add_sub_bool_el(plist_t node, uint8_t val); |
| 61 | void plist_add_sub_uint_el(plist_t node, uint64_t val); | 61 | void plist_add_sub_uint_el(plist_t node, uint64_t val); |
| 62 | void plist_add_sub_real_el(plist_t node, double val); | 62 | void plist_add_sub_real_el(plist_t node, double val); |
| 63 | void plist_add_sub_data_el(plist_t node, char* val, uint64_t length); | 63 | void plist_add_sub_data_el(plist_t node, const char* val, uint64_t length); |
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | //plist free | 66 | //plist free |
| @@ -72,9 +72,9 @@ plist_t plist_get_next_sibling(plist_t node); | |||
| 72 | plist_t plist_get_prev_sibling(plist_t node); | 72 | plist_t plist_get_prev_sibling(plist_t node); |
| 73 | 73 | ||
| 74 | //utili function to find first (and only the first encountred) corresponding node | 74 | //utili function to find first (and only the first encountred) corresponding node |
| 75 | plist_t plist_find_node(plist_t plist, plist_type type, void *value, uint64_t length); | 75 | plist_t plist_find_node(plist_t plist, plist_type type, const void *value, uint64_t length); |
| 76 | plist_t plist_find_node_by_key(plist_t plist, char *value); | 76 | plist_t plist_find_node_by_key(plist_t plist, const char *value); |
| 77 | plist_t plist_find_node_by_string(plist_t plist, char *value); | 77 | plist_t plist_find_node_by_string(plist_t plist, const char *value); |
| 78 | 78 | ||
| 79 | void plist_get_type_and_value(plist_t node, plist_type * type, void *value, uint64_t * length); | 79 | void plist_get_type_and_value(plist_t node, plist_type * type, void *value, uint64_t * length); |
| 80 | 80 | ||
diff --git a/src/plist.c b/src/plist.c index 74868cc..709f12d 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -71,7 +71,7 @@ plist_t plist_new_array() | |||
| 71 | return plist_new_node(data); | 71 | return plist_new_node(data); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | plist_t plist_add_sub_element(plist_t node, plist_type type, void *value, uint64_t length) | 74 | plist_t plist_add_sub_element(plist_t node, plist_type type, const void *value, uint64_t length) |
| 75 | { | 75 | { |
| 76 | //only structured types can have children | 76 | //only structured types can have children |
| 77 | plist_type node_type = plist_get_node_type(node); | 77 | plist_type node_type = plist_get_node_type(node); |
| @@ -140,7 +140,7 @@ plist_t plist_get_prev_sibling(plist_t node) | |||
| 140 | return (plist_t) g_node_prev_sibling((GNode *) node); | 140 | return (plist_t) g_node_prev_sibling((GNode *) node); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | static char compare_node_value(plist_type type, plist_data_t data, void *value, uint64_t length) | 143 | static char compare_node_value(plist_type type, plist_data_t data, const void *value, uint64_t length) |
| 144 | { | 144 | { |
| 145 | char res = FALSE; | 145 | char res = FALSE; |
| 146 | switch (type) { | 146 | switch (type) { |
| @@ -172,7 +172,7 @@ static char compare_node_value(plist_type type, plist_data_t data, void *value, | |||
| 172 | return res; | 172 | return res; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | plist_t plist_find_node(plist_t plist, plist_type type, void *value, uint64_t length) | 175 | plist_t plist_find_node(plist_t plist, plist_type type, const void *value, uint64_t length) |
| 176 | { | 176 | { |
| 177 | if (!plist) | 177 | if (!plist) |
| 178 | return NULL; | 178 | return NULL; |
| @@ -194,12 +194,12 @@ plist_t plist_find_node(plist_t plist, plist_type type, void *value, uint64_t le | |||
| 194 | return NULL; | 194 | return NULL; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | plist_t plist_find_node_by_key(plist_t plist, char *value) | 197 | plist_t plist_find_node_by_key(plist_t plist, const char *value) |
| 198 | { | 198 | { |
| 199 | return plist_find_node(plist, PLIST_KEY, value, strlen(value)); | 199 | return plist_find_node(plist, PLIST_KEY, value, strlen(value)); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | plist_t plist_find_node_by_string(plist_t plist, char *value) | 202 | plist_t plist_find_node_by_string(plist_t plist, const char *value) |
| 203 | { | 203 | { |
| 204 | return plist_find_node(plist, PLIST_STRING, value, strlen(value)); | 204 | return plist_find_node(plist, PLIST_STRING, value, strlen(value)); |
| 205 | } | 205 | } |
| @@ -268,12 +268,12 @@ void plist_add_sub_node(plist_t node, plist_t subnode) | |||
| 268 | } | 268 | } |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | void plist_add_sub_key_el(plist_t node, char *val) | 271 | void plist_add_sub_key_el(plist_t node, const char *val) |
| 272 | { | 272 | { |
| 273 | plist_add_sub_element(node, PLIST_KEY, val, strlen(val)); | 273 | plist_add_sub_element(node, PLIST_KEY, val, strlen(val)); |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | void plist_add_sub_string_el(plist_t node, char *val) | 276 | void plist_add_sub_string_el(plist_t node, const char *val) |
| 277 | { | 277 | { |
| 278 | plist_add_sub_element(node, PLIST_STRING, val, strlen(val)); | 278 | plist_add_sub_element(node, PLIST_STRING, val, strlen(val)); |
| 279 | } | 279 | } |
| @@ -293,7 +293,7 @@ void plist_add_sub_real_el(plist_t node, double val) | |||
| 293 | plist_add_sub_element(node, PLIST_REAL, &val, sizeof(double)); | 293 | plist_add_sub_element(node, PLIST_REAL, &val, sizeof(double)); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | void plist_add_sub_data_el(plist_t node, char *val, uint64_t length) | 296 | void plist_add_sub_data_el(plist_t node, const char *val, uint64_t length) |
| 297 | { | 297 | { |
| 298 | plist_add_sub_element(node, PLIST_DATA, val, length); | 298 | plist_add_sub_element(node, PLIST_DATA, val, length); |
| 299 | } | 299 | } |
