Skip to content

Commit

Permalink
use NULL instead of EMPTYLIST
Browse files Browse the repository at this point in the history
  • Loading branch information
HiGarfield committed Oct 3, 2024
1 parent 04b66ed commit 06e4320
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
} \
} while (0)

#define EMPTYLIST NULL

void init_list(struct list *l, int keysize)
{
l->first = l->last = NULL;
Expand Down Expand Up @@ -137,7 +135,7 @@ struct list_node *xlocate_node(struct list *l, const void *elem, int offset, int
return (tmp);
tmp = tmp->next;
}
return EMPTYLIST;
return NULL;
}

struct list_node *locate_node(struct list *l, const void *elem)
Expand All @@ -158,27 +156,27 @@ void *locate_elem(struct list *l, const void *elem)

void clear_list(struct list *l)
{
while (l->first != EMPTYLIST)
while (l->first != NULL)
{
struct list_node *tmp;
tmp = l->first;
l->first = l->first->next;
safe_free(tmp);
}
l->last = EMPTYLIST;
l->last = NULL;
l->count = 0;
}

void destroy_list(struct list *l)
{
while (l->first != EMPTYLIST)
while (l->first != NULL)
{
struct list_node *tmp;
tmp = l->first;
l->first = l->first->next;
safe_free(tmp->data);
safe_free(tmp);
}
l->last = EMPTYLIST;
l->last = NULL;
l->count = 0;
}

0 comments on commit 06e4320

Please sign in to comment.