代码实现
int getDoubListLen(st_doubNode * head){
int len = 0;
st_doubNode * p = NULL;
if(NULL == head){
goto out;
}
p = head;
while(NULL != p){
len++;
p = p->next;
}
out:
return len;
}
void testgetDoubListLen(void){
int len = 0;
printf("************ testCreateDoubList ************ \n");
len = getDoubListLen(gDoubHead);
printf("len = %d \n", len);
return;
}
调试编译
gcc doublist.c listMain.c -DDEBUG -o a.exe
调试输出
************ testCreateDoubList ************
========= Dump Double List 0xa08010 ===========
22 32 19 53 0 47 29 116 4 6
===================================
************ testCreateDoubList ************
len = 10