Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
WOLFIE-OG committed Jun 24, 2024
1 parent 2e64d7e commit fcb3ba6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: otodd <otodd@student.42london.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/02/13 17:49:05 by otodd #+# #+# #
# Updated: 2024/06/24 17:14:20 by otodd ### ########.fr #
# Updated: 2024/06/24 18:05:36 by otodd ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -136,6 +136,7 @@ UTIL_SRCS = $(UTIL_DIR)/ft_numlen.c \
$(UTIL_DIR)/ft_max.c \
$(UTIL_DIR)/ft_free_array.c \
$(UTIL_DIR)/ft_strarrayappend.c \
$(UTIL_DIR)/ft_strarrayappend2.c \
$(UTIL_DIR)/ft_strarraycat.c \
$(UTIL_DIR)/ft_strarraycpy.c \
$(UTIL_DIR)/ft_strarraydup.c \
Expand Down
3 changes: 2 additions & 1 deletion include/libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: otodd <otodd@student.42london.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 18:36:11 by otodd #+# #+# */
/* Updated: 2024/06/24 17:13:59 by otodd ### ########.fr */
/* Updated: 2024/06/24 18:05:41 by otodd ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -162,6 +162,7 @@ char **ft_strarraycpy(char **dest, char **src);
char **ft_strarrayjoin(char **a1, char **a2);
char **ft_strarraydup(char **a);
char **ft_strarrayappend(char **a, char *s);
char **ft_strarrayappend2(char **a, char *s);
char *ft_strarraychr(char **a, char **c);
char *ft_strarraytostr(char **arr);
char *ft_file_extension(char *str);
Expand Down
31 changes: 31 additions & 0 deletions src/utils/ft_strarrayappend2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strarrayappend2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: otodd <otodd@student.42london.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/14 13:03:18 by otodd #+# #+# */
/* Updated: 2024/06/24 18:08:56 by otodd ### ########.fr */
/* */
/* ************************************************************************** */

#include "../../include/libft.h"

char **ft_strarrayappend2(char **a, char *s)
{
char **new_array;
char **tmp;

if (!a)
{
new_array = malloc(sizeof(char *) * 2);
new_array[0] = s;
new_array[1] = NULL;
return (new_array);
}
new_array = (char **)malloc((ft_strarraylen(a) + 2) * sizeof(char *));
tmp = ft_strarraycpy(new_array, a);
free(a);
return (ft_strarraystrcat(tmp, s));
}

0 comments on commit fcb3ba6

Please sign in to comment.