t_list *new_list(void) { t_list *list; if ((list = malloc(sizeof(t_list))) == NULL) { my_fputstr(STDERR, "Memory allocation failed.\n"); return (NULL); } list->first = NULL; return (list); }
static int close_files(t_list *files) { int i; int size; t_link *tmp; i = 0; size = size_list(files); tmp = files->first; while (i < size) { if (((t_file *)tmp->data)->fd != 0 && close(((t_file *)tmp->data)->fd) == -1) { my_fputstr(STDERR, "Can't close '"); my_fputstr(STDERR, ((t_file *)tmp->data)->name); return (ECLOSE); } i = i + 1; tmp = tmp->next; } return (SUCCESS); }
int my_putstr(const char *str) { return (my_fputstr(STD_OUTPUT, str)); }