X-Git-Url: https://www.hackdaworld.org/gitweb/?a=blobdiff_plain;f=list%2Flist.c;h=0cfb44166f0f99184c8dfbeb488b5e5a15d03eba;hb=97756a0d0fba8437bc029fbece8b48fb4846b00f;hp=a64997f8688f315af954bc052a04fe7b83e4bfef;hpb=d06f6855b63cd0a86eb6ac3948523dbcee997efa;p=my-code%2Fapi.git diff --git a/list/list.c b/list/list.c index a64997f..0cfb441 100644 --- a/list/list.c +++ b/list/list.c @@ -83,12 +83,17 @@ int list_search_data(t_list *list,void *data,int first_bytes) { list_reset(list); - while(list->current!=NULL) { - if(first_bytes<=list->current->data_len) - if(!(memcmp(list->current->data,data,first_bytes))) return L_SUCCESS; - list_next(list); + if(list->start==NULL) { + dprintf(list->outfd,"[list] empty list\n"); + return L_EMPTY_LIST; } + do { + if(list->current!=NULL) + if(first_bytes<=list->current->data_len) + if(!(memcmp(list->current->data,data,first_bytes))) return L_SUCCESS; + } while(list_next(list)!=L_NO_NEXT_ELEMENT); + return L_NO_SUCH_ELEMENT; }