X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Fapi.git;a=blobdiff_plain;f=list%2Flist.c;h=221b2fb01fe0212348a6f62e6cfc5982721663f2;hp=681db539924fb7242d4f3cbca58bdc18a8cd57ce;hb=7a01a093081adee6313dc0805f91fb84548e092e;hpb=040060604e2dc08d17d900825072aad88206ae3b diff --git a/list/list.c b/list/list.c index 681db53..221b2fb 100644 --- a/list/list.c +++ b/list/list.c @@ -8,5 +8,21 @@ int list_init(t_list *list) { - if(list->type==SINGLE) { - list->start + list-> + list->current=&(list->start); + + return L_SUCCESS; +} + +int list_add_element(t_list *list,int nr,void *data,int len) { + + if(list->method&C_NUMBER) { + while(list->current->next!=NULL) { + if(list->current->number==nr) return L_EXISTS; + else list->current=list->current->next; + } + if(list->current->number==nr) return L_EXISTS; + + /* new element */ + if((list->current->next=(t_list *)malloc(sizeof(t_list)))==NULL) { + fprintf(stderr,"[list]