Skip to content

Commit

Permalink
Merge branch 'main' into init_makefile_libft
Browse files Browse the repository at this point in the history
  • Loading branch information
Haliris authored Aug 15, 2024
2 parents d9223c2 + 5cabf8e commit 309e90b
Show file tree
Hide file tree
Showing 56 changed files with 1,831 additions and 1 deletion.
15 changes: 15 additions & 0 deletions include/cub3d.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cub3d.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/14 18:13:07 by jteissie #+# #+# */
/* Updated: 2024/08/14 18:13:26 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef CUB3D_H
# define CUB3D_H
#endif
17 changes: 17 additions & 0 deletions libft/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**/*.out
**/*.a
**/*.o
**/.vscode
**/.gch
**/main
**/*.swp
srcs/libftTester/
./libtest/
srcs/libft.h
srcs/libft.h.gch
srcs/libft.so
srcs/Makefile
srcs/libft.a
libft-war-machine/*
test_dump.c
test_main.c
2 changes: 1 addition & 1 deletion libft/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ fclean: clean

re: fclean all

.PHONY: all clean fclean re bonus
.PHONY: all clean fclean re bonus
38 changes: 38 additions & 0 deletions libft/ft_atoi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/22 19:28:31 by jteissie #+# #+# */
/* Updated: 2024/03/23 16:31:12 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_atoi(const char *nptr)
{
int i;
int result;
int minus;

i = 0;
result = 0;
minus = 0;
while (nptr[i] == ' ' || (nptr[i] >= 9 && nptr[i] <= 13))
i++;
if (nptr[i] == '-' || nptr[i] == '+')
{
if (nptr[i] == '-')
minus = 1;
i++;
}
while (nptr[i] >= '0' && nptr[i] <= '9')
{
result = result * 10 + (nptr[i] - '0');
i++;
}
if (minus)
result *= -1;
return (result);
}
27 changes: 27 additions & 0 deletions libft/ft_bzero.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:41:46 by jteissie #+# #+# */
/* Updated: 2024/05/15 15:00:35 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_bzero(void *s, size_t n)
{
unsigned int i;
unsigned char *str;

i = 0;
str = s;
while (i < n)
{
str[i] = '\0';
i++;
}
}
28 changes: 28 additions & 0 deletions libft/ft_calloc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 17:05:28 by jteissie #+# #+# */
/* Updated: 2024/05/22 15:40:09 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void *ft_calloc(size_t nmemb, size_t size)
{
void *ptr;
size_t total_size;

total_size = size * nmemb;
if (total_size < size && total_size != 0)
return (NULL);
ptr = malloc(total_size);
if (!ptr)
return (NULL);
ft_memset(ptr, 0, total_size);
return (ptr);
}
20 changes: 20 additions & 0 deletions libft/ft_isalnum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:31:49 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:57:58 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isalnum(int c)
{
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
return (1);
if (c >= '0' && c <= '9')
return (1);
return (0);
}
18 changes: 18 additions & 0 deletions libft/ft_isalpha.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:42:26 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:58:03 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isalpha(int c)
{
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
return (1);
return (0);
}
18 changes: 18 additions & 0 deletions libft/ft_isascii.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 17:06:25 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:58:10 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isascii(int c)
{
if (c > 127 || c < 0)
return (0);
return (1);
}
18 changes: 18 additions & 0 deletions libft/ft_isdigit.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:33:38 by jteissie #+# #+# */
/* Updated: 2024/05/22 14:58:16 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isdigit(int c)
{
if (c >= '0' && c <= '9')
return (1);
return (0);
}
18 changes: 18 additions & 0 deletions libft/ft_isprint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 16:43:06 by jteissie #+# #+# */
/* Updated: 2024/03/24 18:13:36 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

int ft_isprint(int c)
{
if (c >= 32 && c <= 126)
return (c);
return (0);
}
63 changes: 63 additions & 0 deletions libft/ft_itoa.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/23 17:10:20 by jteissie #+# #+# */
/* Updated: 2024/05/19 11:34:35 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_putnbr_array(char *str, int nb, int *index)
{
long int number;

number = nb;
if (number < 0)
{
str[0] = '-';
number *= -1;
*index = *index + 1;
}
if (number > 9)
{
ft_putnbr_array(str, number / 10, index);
str[*index] = number % 10 + '0';
*index = *index + 1;
return ;
}
str[*index] = number + '0';
*index = *index + 1;
return ;
}

char *ft_itoa(int n)
{
int digits;
char *string;
int digits_count;
int i;

digits = n;
digits_count = 0;
i = 0;
if (n == 0)
digits_count = 1;
while (digits != 0)
{
digits /= 10;
digits_count++;
}
if (n < 0)
digits_count++;
string = malloc(sizeof(char) * (digits_count + 1));
if (!string)
return (NULL);
ft_putnbr_array(string, n, &i);
string[i] = '\0';
return (string);
}
28 changes: 28 additions & 0 deletions libft/ft_lstadd_back_bonus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_back_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/18 14:45:13 by jteissie #+# #+# */
/* Updated: 2024/05/20 14:08:42 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *last;

if (lst == NULL || new == NULL)
return ;
if (*lst == NULL)
*lst = new;
else
{
last = ft_lstlast(*lst);
last->next = new;
}
}
19 changes: 19 additions & 0 deletions libft/ft_lstadd_front_bonus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_front_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/17 16:46:06 by jteissie #+# #+# */
/* Updated: 2024/05/20 16:40:39 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_lstadd_front(t_list **lst, t_list *new)
{
new->next = *lst;
*lst = new;
}
27 changes: 27 additions & 0 deletions libft/ft_lstclear_bonus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/18 18:10:45 by jteissie #+# #+# */
/* Updated: 2024/05/20 16:57:50 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *temp;

while (*lst != NULL)
{
temp = *lst;
*lst = (*lst)->next;
del(temp->content);
free(temp);
}
lst = NULL;
}
19 changes: 19 additions & 0 deletions libft/ft_lstdelone_bonus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdelone_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/18 15:18:30 by jteissie #+# #+# */
/* Updated: 2024/05/20 15:32:18 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_lstdelone(t_list *lst, void (*del)(void *))
{
del(lst->content);
free(lst);
}
Loading

0 comments on commit 309e90b

Please sign in to comment.