summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index 1b9f4d4..05d760c 100644
--- a/src/list.c
+++ b/src/list.c
@@ -157,7 +157,7 @@ H_ATTR
NUM
list_length(const List * const restrict ls)
{
- return ls->len;
+ return (ls == NULL) ? 0 : ls->len;
}
BOOL
@@ -231,7 +231,7 @@ List *
array_to_list(void **array, NUM size)
{
List *ls = NULL;
-
+
SAFE_MALLOC(List, ls, 1, return NULL;);
ls->array = array;
@@ -243,6 +243,8 @@ array_to_list(void **array, NUM size)
void
destroy_list(List *ls, BOOL all_free_p)
{
+ if (ls == NULL) return;
+
if (all_free_p == 1)
for (NUM i = 0; i < ls->len; i++)
free(*(ls->array+i));