comparison 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
comparison
equal deleted inserted replaced
133:2562c18c904e 134:42592ea2966f
33 char *args; 33 char *args;
34 {int i; 34 {int i;
35 char **argv,*p,*q; 35 char **argv,*p,*q;
36 int argc,n,quote,c; 36 int argc,n,quote,c;
37 initheap(); 37 initheap();
38 stdin = malloc(sizeof(FILE)*3); initfp(stdin,0); 38 stdin = (FILE*) malloc(sizeof(FILE)); initfp(stdin,0);
39 stdout = (FILE*)(((char*)stdin)+sizeof(FILE)); initfp(stdout,1); 39 stdout = (FILE*) malloc(sizeof(FILE)); initfp(stdout,1);
40 stderr = (FILE*)(((char*)stdout)+sizeof(FILE)); initfp(stderr,2); 40 stderr = (FILE*) malloc(sizeof(FILE)); initfp(stderr,2);
41 for ( i = 3; i < NFILES; i++ ) _fcbtbl[i] = NULL; 41 for ( i = 3; i < NFILES; i++ ) _fcbtbl[i] = NULL;
42 /* create argv here */ 42 /* create argv here */
43 argc = 0; 43 argc = 0;
44 argv = 0; 44 argv = 0;
45 for( i = 0; i < 2 ; i++ ) { 45 for( i = 0; i < 2 ; i++ ) {
98 initfp(fp,d) 98 initfp(fp,d)
99 FILE *fp; 99 FILE *fp;
100 int fd; 100 int fd;
101 { 101 {
102 fp->fd = d; 102 fp->fd = d;
103 fp->buf = (char*)malloc(BUFSIZ); 103 fp->buf = (char*)malloc(BUFSIZ+1);
104 fp->ptr = fp->buf; 104 fp->ptr = fp->buf;
105 fp->fname = fp->length = fp->fmode = 0; 105 fp->fname = fp->length = fp->fmode = 0;
106 } 106 }
107 107
108 FILE *fopen(name,mode) 108 FILE *fopen(name,mode)