X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fcerr.c;h=c0146a2899f014f0e2a2b54fd85309b4b2ccfaf4;hp=5443c3e6a53b90d4195a8f40f2528de3dbea124c;hb=b0f981469cdea23225ca5c3ef0ca6759d6a92b43;hpb=406fd6490ad76b4573b6ce9f8d322d92f13d27d8 diff --git a/src/cerr.c b/src/cerr.c index 5443c3e..c0146a2 100644 --- a/src/cerr.c +++ b/src/cerr.c @@ -17,20 +17,18 @@ bool addcerrlist(int newerrc, CERRARRAY newerrv[]) assert(newerrc > 0 && newerrv != NULL); if(cerr != NULL) { - p = cerr; - while (p != NULL) { + for(p = cerr; p != NULL; p = p->next) { q = p; - p = p->next; } - if((p = q->next = malloc(sizeof(CERRLIST *))) == NULL) { + if((p = q->next = malloc(sizeof(CERRLIST))) == NULL) { goto addcerrlisterr; } - } else if((p = cerr = malloc(sizeof(CERRLIST *))) == NULL) { + } else if((p = cerr = malloc(sizeof(CERRLIST))) == NULL) { goto addcerrlisterr; } for(i = 0; i < newerrc; i++) { p->err = &(newerrv[i]); - if((p->next = malloc(sizeof(CERRLIST *))) == NULL) { + if((p->next = malloc(sizeof(CERRLIST))) == NULL) { goto addcerrlisterr; } q = p;