diff options
| author | 2021-12-22 03:17:26 +0100 | |
|---|---|---|
| committer | 2021-12-22 03:17:26 +0100 | |
| commit | 70f4a422e01910cdb783aac81f13c11223c3acbd (patch) | |
| tree | 1279c0edd8b84b91d6a9bc757ea5dc8232f4d78f /src/plist.c | |
| parent | 810e1a5936867a9f2c9f07df3a33a9d02fc03466 (diff) | |
| download | libplist-70f4a422e01910cdb783aac81f13c11223c3acbd.tar.gz libplist-70f4a422e01910cdb783aac81f13c11223c3acbd.tar.bz2 | |
Add a return value to plist_to_* and plist_from_* functions
This way it can be easier determined why an import/export operation failed
instead of just having a NULL result.
Diffstat (limited to 'src/plist.c')
| -rw-r--r-- | src/plist.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/plist.c b/src/plist.c index 5453176..61b2913 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -183,18 +183,22 @@ PLIST_API int plist_is_binary(const char *plist_data, uint32_t length) | |||
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | 185 | ||
| 186 | PLIST_API void plist_from_memory(const char *plist_data, uint32_t length, plist_t * plist) | 186 | PLIST_API plist_err_t plist_from_memory(const char *plist_data, uint32_t length, plist_t * plist) |
| 187 | { | 187 | { |
| 188 | if (length < 8) { | 188 | int res = -1; |
| 189 | *plist = NULL; | 189 | if (!plist) { |
| 190 | return; | 190 | return PLIST_ERR_INVALID_ARG; |
| 191 | } | ||
| 192 | *plist = NULL; | ||
| 193 | if (!plist_data || length < 8) { | ||
| 194 | return PLIST_ERR_INVALID_ARG; | ||
| 191 | } | 195 | } |
| 192 | |||
| 193 | if (plist_is_binary(plist_data, length)) { | 196 | if (plist_is_binary(plist_data, length)) { |
| 194 | plist_from_bin(plist_data, length, plist); | 197 | res = plist_from_bin(plist_data, length, plist); |
| 195 | } else { | 198 | } else { |
| 196 | plist_from_xml(plist_data, length, plist); | 199 | res = plist_from_xml(plist_data, length, plist); |
| 197 | } | 200 | } |
| 201 | return res; | ||
| 198 | } | 202 | } |
| 199 | 203 | ||
| 200 | plist_t plist_new_node(plist_data_t data) | 204 | plist_t plist_new_node(plist_data_t data) |
