Archived
1
0

finish part1 - to correct memchr & memcmp & strnstr

This commit is contained in:
Adam Joly
2023-11-08 17:30:41 +01:00
parent 52e89b462c
commit c29637ab4d
5 changed files with 21 additions and 14 deletions

View File

@ -6,7 +6,7 @@
# By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ # # By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2023/11/01 11:03:22 by adjoly #+# #+# # # Created: 2023/11/01 11:03:22 by adjoly #+# #+# #
# Updated: 2023/11/08 12:14:33 by adjoly ### ########.fr # # Updated: 2023/11/08 17:07:14 by adjoly ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -36,11 +36,13 @@ SRCS = ft_atoi.c \
ft_strlcat.c \ ft_strlcat.c \
ft_strjoin.c \ ft_strjoin.c \
ft_strncmp.c \ ft_strncmp.c \
ft_strchr.c \
ft_itoa.c \ ft_itoa.c \
ft_calloc.c \ ft_calloc.c \
ft_memchr.c \ ft_memchr.c \
ft_memcmp.c \ ft_memcmp.c \
ft_strchr.c \
ft_strrchr.c \
ft_strnstr.c \
OBJS = $(SRCS:.c=.o) OBJS = $(SRCS:.c=.o)
@ -51,9 +53,9 @@ HEADER = libft.h
$(NAME): $(OBJS) $(NAME): $(OBJS)
ar -rcs $(NAME) $(OBJS) ar -rcs $(NAME) $(OBJS)
so: # so:
$(CC) -nostartfiles -fPIC $(CFLAGS) $(SRCS) # $(CC) -nostartfiles -fPIC $(CFLAGS) $(SRCS)
gcc -nostartfiles -shared -o libft.so $(OBJS) # gcc -nostartfiles -shared -o libft.so $(OBJS)
%.o: %.c %.o: %.c
$(CC) $(FLAGS) -I $(HEADER) $< -c -o $@ $(CC) $(FLAGS) -I $(HEADER) $< -c -o $@

View File

@ -6,12 +6,14 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */ /* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
/* Updated: 2023/11/08 11:59:58 by adjoly ### ########.fr */ /* Updated: 2023/11/08 14:52:06 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
#define BUFFER_SIZE 10
void *ft_memchr(const void *s, int c, size_t n) void *ft_memchr(const void *s, int c, size_t n)
{ {
size_t i; size_t i;

View File

@ -6,17 +6,18 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */ /* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */
/* Updated: 2023/11/08 12:17:21 by adjoly ### ########.fr */ /* Updated: 2023/11/08 14:31:21 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c) char *ft_strchr(const char *s, int c)
{ {
int i; size_t len_s;
char *result;
i = 0;
while (s[i])
{
} len_s = ft_strlen(s);
result = ft_memchr(s, c, len_s);
return (result);
} }

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/01 10:06:03 by adjoly #+# #+# */ /* Created: 2023/11/01 10:06:03 by adjoly #+# #+# */
/* Updated: 2023/11/08 12:14:58 by adjoly ### ########.fr */ /* Updated: 2023/11/08 17:08:26 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -46,5 +46,7 @@ char *ft_itoa(int n);
void *ft_memmove(void *dest, const void *src, size_t n); void *ft_memmove(void *dest, const void *src, size_t n);
void *ft_memchr(const void *s, int c, size_t n); void *ft_memchr(const void *s, int c, size_t n);
int ft_memcmp(const void *s1, const void *s2, size_t n); int ft_memcmp(const void *s1, const void *s2, size_t n);
char *ft_strrchr(const char *s, int c);
char *ft_strnstr(const char *big, const char *little, size_t len);
#endif #endif

BIN
libft.so

Binary file not shown.