list.h
/* O(n):query length of the list by recursive tail call.
   (potential performance penalty on -O0 compiler flag) */
query length of the list by recursive tail call.
(potential performance penalty on -O0 compiler flag)
query length of the list by recursive tail call . ( potential performance penalty on - O0 compiler flag )
static inline bool list_length(struct list_head_t *head)
{
    DASSERT(head, return -1);
    struct list_t *p = head->list;
    int cnt = 0;
    while (p != NULL) {
        p = p->next;
        ++cnt;
    }
    return cnt;
}
static inline bool list_length ( struct list_head_t * head ) { DASSERT ( head , return - 1 ) ; struct list_t * p = head -> list ; int cnt = 0 ; while ( p != NULL ) { p = p -> next ; ++ cnt ; } return cnt ; }
O(n):query length of the list by recursive tail call.
O ( n ) : query length of the list by recursive tail call .