Fix c_list_length() function.

This commit is contained in:
Andreas Schneider 2008-05-20 11:14:16 +02:00
parent 287a37d447
commit 679927b5a9

View file

@ -199,6 +199,10 @@ c_list_t *c_list_alloc(void) {
c_list_t *c_list_remove(c_list_t *list, void *data) {
c_list_t *temp = NULL;
if (list == NULL || data == NULL) {
return NULL;
}
temp = list;
while (temp != NULL) {
@ -275,14 +279,16 @@ c_list_t *c_list_previous(c_list_t *list) {
* Gets the number of elements in a c_list
*/
unsigned long c_list_length(c_list_t *list) {
unsigned long length = 0;
unsigned long length = 1;
if (list == NULL) {
return 0;
}
if (list != NULL) {
while (list->next) {
length++;
list = list->next;
}
}
return length;
}