aboutsummaryrefslogtreecommitdiff
path: root/include/sqfs/predef.h
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@microsoft.com>2021-07-30 15:56:11 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-30 22:31:30 +0200
commita0c0f38cb947a16a5aebf2b59fb8481866d28f96 (patch)
treecdb566c89666f62b78bd3e432140aa86b23bf67a /include/sqfs/predef.h
parent7667b84cc34707c28ca0db8d24f046ec34e8c25d (diff)
sqfs_dir_tree_destroy/sqfs_destroy: allow NULL input
Many library destructor functions (like free()) allow a NULL pointer as input, and do nothing in that case. This allows easier cleanup patterns: initialize pointers to NULL and then always pass them to the destroyer functions, no need for verbose goto/if-else patterns. Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
Diffstat (limited to 'include/sqfs/predef.h')
-rw-r--r--include/sqfs/predef.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index 6296b4b..a976cd4 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -133,11 +133,12 @@ typedef struct sqfs_object_t {
*
* @memberof sqfs_object_t
*
- * @param obj A pointer to an object
+ * @param obj A pointer to an object or NULL
*/
static SQFS_INLINE void sqfs_destroy(void *obj)
{
- ((sqfs_object_t *)obj)->destroy((sqfs_object_t *)obj);
+ if (obj)
+ ((sqfs_object_t *)obj)->destroy((sqfs_object_t *)obj);
}
/**