X-Git-Url: http://j8takagi.net/cgi-bin/gitweb.cgi?p=YACASL2.git;a=blobdiff_plain;f=src%2Fcerr.c;h=455ab5b701cded1f9b1f12628fe19e13812f31c6;hp=f1cb09c0ce68d9df1b290b9389d0dfea548324cc;hb=86e559d164166966a797a1e5855871d48e087ddd;hpb=1708c99d4b6263863304d48ebca3b3473d6a0112 diff --git a/src/cerr.c b/src/cerr.c index f1cb09c..455ab5b 100644 --- a/src/cerr.c +++ b/src/cerr.c @@ -1,8 +1,3 @@ -#include -#include -#include -#include -#include #include "cerr.h" void cerr_init() @@ -11,32 +6,32 @@ void cerr_init() cerr->num = 0; } -CERR *cerr; +CERR *cerr = NULL; CERRLIST *cerrlist = NULL; void addcerrlist(int cerrc, CERR cerrv[]) { - int i; - CERRLIST *p = NULL, *q = malloc_chk(sizeof(CERRLIST), "cerrlist"); + CERRLIST *stat = NULL; + CERRLIST *p = NULL; assert(cerrc > 0 && cerrv != NULL); - for(i = 0; i < cerrc; i++) { + for(int i = 0; i < cerrc; i++) { if(p == NULL) { - p = q; + stat = p = malloc_chk(sizeof(CERRLIST), "cerrlist"); } else { - p = p->next = malloc_chk(sizeof(CERRLIST), "cerrlist.next"); + p = p->next = malloc_chk(sizeof(CERRLIST), "cerrlist->next"); } p->cerr = &cerrv[i]; p->next = NULL; } p->next = cerrlist; - cerrlist = q; + cerrlist = stat; } void printcerrlist() { - CERRLIST *p; + CERRLIST *p = NULL; if(cerrlist == NULL) { puts("error list is null."); @@ -62,7 +57,7 @@ void setcerr(int num, const char *str) char *getcerrmsg(int num) { - CERRLIST *p; + CERRLIST *p = NULL; char *msg = "unknown error"; for(p = cerrlist; p != NULL; p = p->next) { @@ -76,7 +71,8 @@ char *getcerrmsg(int num) void freecerr() { - CERRLIST *p = cerrlist, *q; + CERRLIST *p = NULL; + CERRLIST *q = NULL; /* 現在のエラーメッセージを解放 */ FREE(cerr->msg);