sniperHW / chuck

high performance and easily use asynchronous network library for C/Lua
52 stars 32 forks source link

chk_list.h 文件里 chk_list_pushback 函数 #12

Open zzh442856860 opened 7 years ago

zzh442856860 commented 7 years ago

//if push success,return the new size,else return -1 static inline size_t chk_list_pushback(chk_list l,chk_list_entry n) { if(n->next) return chk_error_common; if(0 == l->size) l->head = l->tail = n; else { l->tail->next = n; //这个尾指针的next,不应该是null吗,为何还是自己? l->tail = n; } ++l->size; return chk_error_ok; }

如果成功返回new size;未返回,实际返回chk_error_ok; 如果失败,返回的chk_error_common 是 1, 也不是-1

sniperHW commented 7 years ago

注释没更新,tail 指向最后一个节点 自己画个图就知道什么意思了

发自我的 iPhone

在 2017年1月5日,16:22,nike notifications@github.com 写道:

//if push success,return the new size,else return -1 static inline size_t chk_list_pushback(chk_list l,chk_list_entry n) { if(n->next) return chk_error_common; if(0 == l->size) l->head = l->tail = n; else { l->tail->next = n; //这个尾指针的next,不应该是null吗,为何还是自己? l->tail = n; } ++l->size; return chk_error_ok; }

如果成功返回new size;未返回,实际返回chk_error_ok; 如果失败,返回的chk_error_common 是 1, 也不是-1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.