-
-static struct errlist *error_list_head, *error_list_tail;
-
-/*
- * XXX: this function should not allocate memory as it may be called to
- * print an error because we are out of memory.
- */
-void push_error_list(char * msg)
-{
- struct errlist *e;
-
- e = xcalloc(1, sizeof(struct errlist));
- e->errmsg = xstrdup(msg);
- e->next = NULL;
-
- if (error_list_head) {
- error_list_tail->next = e;
- error_list_tail = e;
- } else {
- error_list_head = error_list_tail = e;
- }
-}
-
-void free_error_list(void)
-{
- struct errlist *err, *err_tmp;
-
- err = error_list_head;
- while (err != NULL) {
- free(err->errmsg);
- err_tmp = err;
- err = err->next;
- free(err_tmp);
- }
-}
-
-void print_error_list (void)
-{
- struct errlist *err = error_list_head;
-
- if (err) {
- printf ("Collected errors:\n");
- /* Here we print the errors collected and free the list */
- while (err != NULL) {
- printf (" * %s", err->errmsg);
- err = err->next;
- }
- }
-}