summaryrefslogtreecommitdiffstats
path: root/src/plist.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-12-22 03:17:26 +0100
committerGravatar Nikias Bassen2021-12-22 03:17:26 +0100
commit70f4a422e01910cdb783aac81f13c11223c3acbd (patch)
tree1279c0edd8b84b91d6a9bc757ea5dc8232f4d78f /src/plist.c
parent810e1a5936867a9f2c9f07df3a33a9d02fc03466 (diff)
downloadlibplist-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.c18
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)
}
-PLIST_API void plist_from_memory(const char *plist_data, uint32_t length, plist_t * plist)
+PLIST_API plist_err_t plist_from_memory(const char *plist_data, uint32_t length, plist_t * plist)
{
- if (length < 8) {
- *plist = NULL;
- return;
+ int res = -1;
+ if (!plist) {
+ return PLIST_ERR_INVALID_ARG;
+ }
+ *plist = NULL;
+ if (!plist_data || length < 8) {
+ return PLIST_ERR_INVALID_ARG;
}
-
if (plist_is_binary(plist_data, length)) {
- plist_from_bin(plist_data, length, plist);
+ res = plist_from_bin(plist_data, length, plist);
} else {
- plist_from_xml(plist_data, length, plist);
+ res = plist_from_xml(plist_data, length, plist);
}
+ return res;
}
plist_t plist_new_node(plist_data_t data)