err = opkg_conf_init (&opkg_conf, &args);
+ args_deinit (&args);
if (err)
{
opkg_print_error_list (&opkg_conf);
return err;
}
- args_deinit (&args);
-
if ( strcmp(cmd_name, "files")==0)
opkg_cb_list = default_opkg_files_callback;
else
void opkg_print_error_list (opkg_conf_t *conf)
{
- if ( error_list ) {
- reverse_error_list(&error_list);
+ struct errlist *err = error_list;
+
+ if (err) {
+ reverse_error_list(&err);
printf ("Collected errors:\n");
/* Here we print the errors collected and free the list */
- while (error_list != NULL) {
- printf (" * %s", error_list->errmsg);
- error_list = error_list->next;
+ while (err != NULL) {
+ printf (" * %s", err->errmsg);
+ err = err->next;
}
- free_error_list();
+
+ free_error_list(&error_list);
}
}
}
}
+ pkg_vec_free(available);
+
return 0;
}
return 1;
}
+/*
+ * 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(struct errlist ** errors, char * msg){
struct errlist *err_lst_tmp;
+ err_lst_tmp = calloc (1, sizeof (struct errlist) );
+ if (err_lst_tmp == NULL) {
+ fprintf(stderr, "%s: calloc: %s\n", __FUNCTION__, strerror(errno));
+ return;
+ }
+
+ err_lst_tmp->errmsg = strdup(msg);
+ if (err_lst_tmp->errmsg == NULL) {
+ fprintf(stderr, "%s: strdup: %s\n", __FUNCTION__, strerror(errno));
+ free(err_lst_tmp);
+ return;
+ }
- err_lst_tmp = calloc (1, sizeof (err_lst_tmp) );
- err_lst_tmp->errmsg=strdup(msg) ;
err_lst_tmp->next = *errors;
*errors = err_lst_tmp;
}
}
-void free_error_list(){
+void free_error_list(struct errlist **errors){
struct errlist *err_tmp_lst;
- err_tmp_lst = error_list;
+ err_tmp_lst = *errors;
while (err_tmp_lst != NULL) {
free(err_tmp_lst->errmsg);
err_tmp_lst = error_list->next;
- free(error_list);
- error_list = err_tmp_lst;
+ free(*errors);
+ *errors = err_tmp_lst;
}
void push_error_list(struct errlist **errors,char * msg);
void reverse_error_list(struct errlist **errors);
-void free_error_list();
+void free_error_list(struct errlist **errors);
long unsigned int get_available_blocks(char * filesystem);
char **read_raw_pkgs_from_file(const char *file_name);