Mercurial > hg > Members > kono > os9 > sbc09
diff os9/mc09/mclibos9.c @ 134:42592ea2966f
fix fclose/mfree problem
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 07 Jan 2019 03:38:10 +0900 |
parents | 2562c18c904e |
children |
line wrap: on
line diff
--- a/os9/mc09/mclibos9.c Sun Jan 06 22:38:04 2019 +0900 +++ b/os9/mc09/mclibos9.c Mon Jan 07 03:38:10 2019 +0900 @@ -35,9 +35,9 @@ char **argv,*p,*q; int argc,n,quote,c; initheap(); - stdin = malloc(sizeof(FILE)*3); initfp(stdin,0); - stdout = (FILE*)(((char*)stdin)+sizeof(FILE)); initfp(stdout,1); - stderr = (FILE*)(((char*)stdout)+sizeof(FILE)); initfp(stderr,2); + stdin = (FILE*) malloc(sizeof(FILE)); initfp(stdin,0); + stdout = (FILE*) malloc(sizeof(FILE)); initfp(stdout,1); + stderr = (FILE*) malloc(sizeof(FILE)); initfp(stderr,2); for ( i = 3; i < NFILES; i++ ) _fcbtbl[i] = NULL; /* create argv here */ argc = 0; @@ -100,7 +100,7 @@ int fd; { fp->fd = d; - fp->buf = (char*)malloc(BUFSIZ); + fp->buf = (char*)malloc(BUFSIZ+1); fp->ptr = fp->buf; fp->fname = fp->length = fp->fmode = 0; }