From 24692371a191df65509a88bd23ac22cbbdf17dc3 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sun, 10 Apr 2016 12:23:23 -0300 Subject: [PATCH] Implementa list_size, retornando tamanho da lista. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Esta função será útil para obter número de dependentes, por exemplo. --- lib/list.c | 5 +++++ lib/list.h | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/list.c b/lib/list.c index 87913c4..8cba3f3 100644 --- a/lib/list.c +++ b/lib/list.c @@ -123,3 +123,8 @@ void list_free(struct list *list, free_function_t *ifree) ifree(list->items[i].val); free(list); } + +int list_size(struct list *list) +{ + return list->len; +} diff --git a/lib/list.h b/lib/list.h index bf09f6f..8521518 100644 --- a/lib/list.h +++ b/lib/list.h @@ -29,5 +29,6 @@ int list_insert(struct list **list, int pos, void *val); int list_insert_ordered(struct list **list, void *val, sort_function_t *fn); void * list_get(struct list *list, int pos); void list_free(struct list *list, free_function_t *ifree); +int list_size(struct list *list); #endif -- 2.20.1