Firstcommit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* debug.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/23 13:23:51 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/08/23 13:23:51 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub.h"
|
||||
|
||||
void print_char_array_debug(char **arr, char *name)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
printf("=== %s ===\n", name ? name : "CHAR ARRAY");
|
||||
|
||||
if (!arr)
|
||||
{
|
||||
printf("Array is NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while (arr[i])
|
||||
{
|
||||
printf("[%d] (%zu chars): '%s'\n", i, strlen(arr[i]), arr[i]);
|
||||
i++;
|
||||
}
|
||||
printf("Total lines: %d\n", i);
|
||||
printf("==============\n");
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* init.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/22 18:57:21 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/08/22 18:57:21 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include "cub.h"
|
||||
|
||||
int init_data(t_data *data, char *path)
|
||||
{
|
||||
if (!data)
|
||||
return (ft_error(ERROR_INIT_DATA), 1);
|
||||
data->texture = malloc(sizeof(t_textures));
|
||||
if (!data->texture)
|
||||
return (ft_error(ERROR_INIT_TEX), 1);
|
||||
init_parsing(&data->parsing);
|
||||
init_textures(data->texture);
|
||||
data->map = NULL;
|
||||
data->map_path = path;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void free_data(t_data *data)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
if (data->texture)
|
||||
free(data->texture);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lfirmin <[email protected]> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/08/22 14:56:25 by lfirmin #+# #+# */
|
||||
/* Updated: 2025/08/22 14:56:25 by lfirmin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub.h"
|
||||
|
||||
void ft_error(char *message)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = 0;
|
||||
while (message[len])
|
||||
len++;
|
||||
write(2, ERROR_PREFIX, 31);
|
||||
write(2, message, len);
|
||||
write(2, "\n", 1);
|
||||
}
|
||||
|
||||
void free_char_array(char **array)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!array)
|
||||
return;
|
||||
i = 0;
|
||||
while (array[i])
|
||||
free(array[i++]);
|
||||
free(array);
|
||||
}
|
||||
Reference in New Issue
Block a user