// Copyright status: this file is in the public domain. #include #include #include #include "internal.h" void lx__str_tconc_init(STR_TCONC *l) { l->head = 0; l->tail = &l->head; } int lx__str_tconc_push_printf(STR_TCONC *sl, const char *fmt, ...) { char *s; int l; STR_ENTRY *e; va_list ap; e = malloc(sizeof(STR_ENTRY)); if (! e) return(1); va_start(ap,fmt); l = vasprintf(&s,fmt,ap); va_end(ap); if (l < 0) { free(e); return(1); } printf("strlist_push_printf() pushing: %s\n",s); e->str = s; e->link = 0; *sl->tail = e; sl->tail = &e->link; return(0); } void lx__str_tconc_flush(STR_TCONC *l) { STR_ENTRY *e; while ((e = l->head)) { l->head = e->link; free(e->str); free(e); } l->tail = &l->head; }