- err_lst_tmp = calloc (1, sizeof (err_lst_tmp) );
- err_lst_tmp->errmsg=strdup(msg) ;
- err_lst_tmp->next = *errors;
- *errors = err_lst_tmp;
+/*
+ * 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;
+ }