version 1.9, 2003/06/10 22:20:45 |
version 1.10, 2003/09/26 22:24:09 |
|
|
TBL *t; |
TBL *t; |
int coloff, cnt; |
int coloff, cnt; |
char *p, **lp; |
char *p, **lp; |
int *lens, maxcols; |
int *lens, *lens2, maxcols; |
TBL *tbl; |
TBL *tbl; |
char **cols; |
char **cols, **cols2; |
|
|
t = tbl = emalloc(entries * sizeof(TBL)); |
t = tbl = emalloc(entries * sizeof(TBL)); |
cols = emalloc((maxcols = DEFCOLS) * sizeof(char *)); |
cols = emalloc((maxcols = DEFCOLS) * sizeof(char *)); |
|
|
for (coloff = 0, p = *lp; (cols[coloff] = strtok(p, separator)); |
for (coloff = 0, p = *lp; (cols[coloff] = strtok(p, separator)); |
p = NULL) |
p = NULL) |
if (++coloff == maxcols) { |
if (++coloff == maxcols) { |
if (!(cols = realloc(cols, (u_int)maxcols + |
if (!(cols2 = realloc(cols, (u_int)maxcols + |
DEFCOLS * sizeof(char *))) || |
DEFCOLS * sizeof(char *))) || |
!(lens = realloc(lens, |
!(lens2 = realloc(lens, |
(u_int)maxcols + DEFCOLS * sizeof(int)))) |
(u_int)maxcols + DEFCOLS * sizeof(int)))) |
err(1, NULL); |
err(1, NULL); |
|
cols = cols2; |
|
lens = lens2; |
memset((char *)lens + maxcols * sizeof(int), |
memset((char *)lens + maxcols * sizeof(int), |
0, DEFCOLS * sizeof(int)); |
0, DEFCOLS * sizeof(int)); |
maxcols += DEFCOLS; |
maxcols += DEFCOLS; |