#include "defs.h"#include "iob.h"Include dependency graph for mem.c:

Go to the source code of this file.
Data Structures | |
| struct | memblock |
Defines | |
| #define | MEMBSIZE 32000 |
| #define | GMEMBSIZE 16000 |
Typedefs | |
| typedef memblock | memblock |
Functions | |
| char * | gmem (int n, int round) |
| void | mem_init (Void) |
| char * | mem (int n, int round) |
| char * | tostring (register char *s, int n) |
| char * | cpstring (register char *s) |
| void | new_iob_data (register io_setup *ios, char *name) |
| char * | string_num (char *pfx, long n) |
| void | def_start (FILE *outfile, char *s1, char *s2, char *post) |
| void | other_undefs (FILE *outfile) |
Variables | |
| static memblock * | mem0 |
| memblock * | curmemblock |
| memblock * | firstmemblock |
| char * | mem_first |
| char * | mem_next |
| char * | mem_last |
| char * | mem0_last |
| static defines * | define_list |
| #define MEMBSIZE 32000 |
| char* cpstring | ( | register char * | s | ) |
Definition at line 177 of file mem.c.
References mem().
Referenced by data_value(), ioseta(), new_iob_data(), and wr_equiv_init().
Here is the call graph for this function:

Here is the caller graph for this function:

| void def_start | ( | FILE * | outfile, | |
| char * | s1, | |||
| char * | s2, | |||
| char * | post | |||
| ) |
Definition at line 233 of file mem.c.
References define_list, defines::defname, in_define, mem(), n1, defines::next, and nice_printf().
Referenced by ref_defs(), wr_common_decls(), wr_one_init(), and write_char_init().
00235 { 00236 defines *d; 00237 int n, n1; 00238 extern int in_define; 00239 00240 n = n1 = strlen(s1); 00241 if (s2) 00242 n += strlen(s2); 00243 d = (defines *)mem(sizeof(defines)+n, 1); 00244 d->next = define_list; 00245 define_list = d; 00246 strcpy(d->defname, s1); 00247 if (s2) 00248 strcpy(d->defname + n1, s2); 00249 in_define = 1; 00250 nice_printf(outfile, "#define %s", d->defname); 00251 if (post) 00252 nice_printf(outfile, " %s", post); 00253 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 40 of file mem.c.
References Alloc(), GMEMBSIZE, last, and mem::next.
Referenced by copy_data(), mkext1(), newarg(), and readref().
00042 { 00043 static char *last, *next; 00044 char *rv; 00045 if (round) 00046 #ifdef CRAY 00047 if ((long)next & 0xe000000000000000) 00048 next = (char *)(((long)next & 0x1fffffffffffffff) + 1); 00049 #else 00050 #ifdef MSDOS 00051 if ((int)next & 1) 00052 next++; 00053 #else 00054 next = (char *)(((long)next + sizeof(char *)-1) 00055 & ~((long)sizeof(char *)-1)); 00056 #endif 00057 #endif 00058 rv = next; 00059 if ((next += n) > last) { 00060 rv = Alloc(n + GMEMBSIZE); 00061 00062 next = rv + n; 00063 last = next + GMEMBSIZE; 00064 } 00065 return rv; 00066 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 97 of file mem.c.
References Alloc(), b, curmemblock, MEMBSIZE, memblock::next, and s.
Referenced by cds(), cpstring(), def_start(), do_p1_charp(), dtos(), fmtname(), ioseta(), mkname(), new_iob_data(), p1getf(), putif(), putwhile(), setfmt(), string_num(), tostring(), and unamstring().
00099 { 00100 memblock *b; 00101 register char *rv, *s; 00102 00103 if (round) 00104 #ifdef CRAY 00105 if ((long)mem_next & 0xe000000000000000) 00106 mem_next = (char *)(((long)mem_next & 0x1fffffffffffffff) + 1); 00107 #else 00108 #ifdef MSDOS 00109 if ((int)mem_next & 1) 00110 mem_next++; 00111 #else 00112 mem_next = (char *)(((long)mem_next + sizeof(char *)-1) 00113 & ~((long)sizeof(char *)-1)); 00114 #endif 00115 #endif 00116 rv = mem_next; 00117 s = rv + n; 00118 if (s >= mem_last) { 00119 if (n > MEMBSIZE) { 00120 fprintf(stderr, "mem(%d) failure!\n", n); 00121 exit(1); 00122 } 00123 if (!(b = curmemblock->next)) { 00124 b = (memblock *)Alloc(sizeof(memblock)); 00125 curmemblock->next = b; 00126 b->next = 0; 00127 } 00128 curmemblock = b; 00129 rv = b->buf; 00130 mem_last = rv + sizeof(b->buf); 00131 s = rv + n; 00132 } 00133 mem_next = s; 00134 return rv; 00135 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void mem_init | ( | Void | ) |
Definition at line 80 of file mem.c.
References Alloc(), memblock::buf, curmemblock, firstmemblock, mem0, MEMBSIZE, and memblock::next.
Referenced by fileinit().
00081 { 00082 curmemblock = firstmemblock = mem0 00083 = (memblock *)Alloc(sizeof(memblock)); 00084 mem_first = mem0->buf; 00085 mem_next = mem0->buf; 00086 mem_last = mem0->buf + MEMBSIZE; 00087 mem0_last = mem0->buf + MEMBSIZE; 00088 mem0->next = 0; 00089 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void new_iob_data | ( | register io_setup * | ios, | |
| char * | name | |||
| ) |
Definition at line 189 of file mem.c.
References cpstring(), iob_data::fields, iob_list, mem(), iob_data::name, iob_data::next, and iob_data::type.
Referenced by startrw().
00191 { 00192 register iob_data *iod; 00193 register char **s, **se; 00194 00195 iod = (iob_data *) 00196 mem(sizeof(iob_data) + ios->nelt*sizeof(char *), 1); 00197 iod->next = iob_list; 00198 iob_list = iod; 00199 iod->type = ios->fields[0]; 00200 iod->name = cpstring(name); 00201 s = iod->fields; 00202 se = s + ios->nelt; 00203 while(s < se) 00204 *s++ = "0"; 00205 *s = 0; 00206 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void other_undefs | ( | FILE * | outfile | ) |
Definition at line 260 of file mem.c.
References define_list, defines::defname, defines::next, and nice_printf().
Referenced by start_formatting().
00262 { 00263 defines *d; 00264 if (d = define_list) { 00265 define_list = 0; 00266 nice_printf(outfile, "\n"); 00267 do 00268 nice_printf(outfile, "#undef %s\n", d->defname); 00269 while(d = d->next); 00270 nice_printf(outfile, "\n"); 00271 } 00272 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* string_num | ( | char * | pfx, | |
| long | n | |||
| ) |
Definition at line 214 of file mem.c.
Referenced by ioset(), and mkcxcon().
00216 { 00217 char buf[32]; 00218 sprintf(buf, "%s%ld", pfx, n); 00219 /* can't trust return type of sprintf -- BSD gets it wrong */ 00220 return strcpy(mem(strlen(buf)+1,0), buf); 00221 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* tostring | ( | register char * | s, | |
| int | n | |||
| ) |
Definition at line 143 of file mem.c.
References mem(), s1, str_fmt, and t.
Referenced by ioseta().
00145 { 00146 register char *s1, *se, **sf; 00147 char *rv, *s0; 00148 register int k = n + 2, t; 00149 00150 sf = str_fmt; 00151 sf['%'] = "%"; 00152 s0 = s; 00153 se = s + n; 00154 for(; s < se; s++) { 00155 t = *(unsigned char *)s; 00156 s1 = sf[t]; 00157 while(*++s1) 00158 k++; 00159 } 00160 sf['%'] = "%%"; 00161 rv = s1 = mem(k,0); 00162 *s1++ = '"'; 00163 for(s = s0; s < se; s++) { 00164 t = *(unsigned char *)s; 00165 sprintf(s1, sf[t], t); 00166 s1 += strlen(s1); 00167 } 00168 *s1 = 0; 00169 return rv; 00170 }
Here is the call graph for this function:

Here is the caller graph for this function:

defines* define_list [static] |
1.5.1