version 1.8, 2001/01/13 18:06:54 |
version 1.9, 2001/01/13 18:12:47 |
|
|
if (filename) { |
if (filename) { |
lb->filename = filename; |
lb->filename = filename; |
if (!(lb->stream = fopen(filename, "r"))) { |
if (!(lb->stream = fopen(filename, "r"))) { |
free(lb); |
xfree(lb); |
if (errfun) |
if (errfun) |
(*errfun) ("%s: %s\n", filename, strerror(errno)); |
(*errfun) ("%s: %s\n", filename, strerror(errno)); |
return (NULL); |
return (NULL); |
|
|
if (!(lb->buf = malloc(lb->size = LINEBUF_SIZE))) { |
if (!(lb->buf = malloc(lb->size = LINEBUF_SIZE))) { |
if (errfun) |
if (errfun) |
(*errfun) ("linebuf (%s): malloc failed\n", lb->filename); |
(*errfun) ("linebuf (%s): malloc failed\n", lb->filename); |
free(lb); |
xfree(lb); |
return (NULL); |
return (NULL); |
} |
} |
lb->errfun = errfun; |
lb->errfun = errfun; |
|
|
Linebuf_free(Linebuf * lb) |
Linebuf_free(Linebuf * lb) |
{ |
{ |
fclose(lb->stream); |
fclose(lb->stream); |
free(lb->buf); |
xfree(lb->buf); |
free(lb); |
xfree(lb); |
} |
} |
|
|
static inline void |
static inline void |
|
|
do { |
do { |
name = xstrsep(&namelist, ","); |
name = xstrsep(&namelist, ","); |
if (!name) { |
if (!name) { |
free(namebase); |
xfree(namebase); |
return (-1); |
return (-1); |
} |
} |
} while ((s = tcpconnect(name)) < 0); |
} while ((s = tcpconnect(name)) < 0); |
|
|
close(s); |
close(s); |
if (s >= maxfd || fdcon[s].c_status == CS_UNUSED) |
if (s >= maxfd || fdcon[s].c_status == CS_UNUSED) |
fatal("confree: attempt to free bad fdno %d", s); |
fatal("confree: attempt to free bad fdno %d", s); |
free(fdcon[s].c_namebase); |
xfree(fdcon[s].c_namebase); |
free(fdcon[s].c_output_name); |
xfree(fdcon[s].c_output_name); |
if (fdcon[s].c_status == CS_KEYS) |
if (fdcon[s].c_status == CS_KEYS) |
free(fdcon[s].c_data); |
xfree(fdcon[s].c_data); |
fdcon[s].c_status = CS_UNUSED; |
fdcon[s].c_status = CS_UNUSED; |
TAILQ_REMOVE(&tq, &fdcon[s], c_link); |
TAILQ_REMOVE(&tq, &fdcon[s], c_link); |
FD_CLR(s, &read_wait); |
FD_CLR(s, &read_wait); |
|
|
char *iname, *oname; |
char *iname, *oname; |
|
|
iname = xstrdup(c->c_namelist); |
iname = xstrdup(c->c_namelist); |
oname = c->c_output_name; |
oname = xstrdup(c->c_output_name); |
c->c_output_name = NULL;/* prevent it from being freed */ |
|
confree(s); |
confree(s); |
ret = conalloc(iname, oname); |
ret = conalloc(iname, oname); |
free(iname); |
xfree(iname); |
|
xfree(oname); |
return (ret); |
return (ret); |
} |
} |
|
|