More guarding against freeing NULL pointers.

This commit is contained in:
Omer Katz 2014-05-21 12:50:56 +03:00
parent 61b3b24e2e
commit 7303bc8f00
2 changed files with 21 additions and 16 deletions

View file

@ -25,6 +25,7 @@ void
list_free(l)
list *l;
{
if (l) {
list_item *li, *tmp;
pthread_mutex_lock(&(l->mutex));
@ -33,7 +34,6 @@ list_free(l)
li = l->head;
while (li != NULL) {
tmp = li->next;
zfree(li);
li = tmp;
}
}
@ -41,6 +41,7 @@ list_free(l)
pthread_mutex_unlock(&(l->mutex));
pthread_mutex_destroy(&(l->mutex));
zfree(l);
}
}
list_item *

View file

@ -21,11 +21,15 @@ str_array * str_array_create(int cap) {
}
void str_array_free(str_array *l) {
if (l) {
for ( int i = 0; i < l->len ; i++ ) {
char * t = l->tokens[ i ];
if (t) {
zfree(t);
}
}
zfree(l);
}
}
bool str_array_is_full(str_array * l) {