25#include <get_next_line_bonus.h>
26#include "utils/utils.h"
59 perror(
"get_next_line()");
64 if (row[row_len - 1] ==
'\n')
93 return (perror(
"malloc()"));
98 return (perror(
"malloc()"));
123 ft_printf(
"%>Inconsistent width on row %d\n", 2, y + 1);
131 return (*(
int *)
err(
"malloc() failed", &x));
161 return (*(
t_map *)
err(
"Cannot draw line from 1 point", (
void *) &map));
167 return (*(
t_map *)
err(
"malloc()", (
void *) &map));
void ** arr_free(void **arr)
Free each element in a null-terminated array, and then the array itself.
int arr_len(void **arr)
Count number of elements in a null-terminated array.
int ft_printf(const char *format,...)
Prints and formats a variable set of arguments.
void * err(const char *str, void *retval)
Wrapper around perror() that always returns retval.
int ft_atoi(const char *str)
Converts ASCII string str to integer representation.
void * ft_calloc(size_t count, size_t size)
Allocates count * size bytes with malloc and returns a pointer to the result.
void ft_lstadd_back(t_list **lst, t_list *new)
Adds node at pointer new to the end of the list starting at pointer pointed to by lst.
void ft_lstclear(t_list **lst, void(*del)(void *))
Delete every node in a list along with it's content.
t_list * ft_lstnew(void *content)
Allocates a new node, set it's content, and return it's address.
int ft_lstsize(t_list *lst)
Counts the number of nodes in a list.
char ** ft_split(char const *s, char c)
Split string s by characer c into allocated array of strings, with NULL as the last element.
size_t ft_strlen(const char *str)
Get length of str.
char * get_next_line(int fd)
Return the next segment of text ending in a newline or EOF from file descriptor fd.
static char * prep_row(char *row, t_list **lst)
Remove trailing newline from row or print appropriate error message.
t_map read_map(int fd)
Initialize map from an fdf map file pointed to by fd.
static int fill_points(t_map *map, t_list *lst)
Allocate map points and set height values from lst.
static void lst_arr_free(void *arr)
Wrapper around arr_free for use with ft_lstclear.
static void split_rows(int fd, t_list **lst)
Read rows from fd and place them into lst nodes, split on spaces.
struct s_list * next
Pointer to the next node.
void * content
void* to the node's contents.
int width
Number of columns in the map.
int height
Number of rows in the map.
t_point ** point
2d array of points in [y][x] order
int height
Height extracted from map file.