some norminettes and error in memorybook when adding a 2d pointer
This commit is contained in:
@@ -11,7 +11,7 @@ _DEP = libft.h
|
||||
DEPS = $(_DEP:%.h=$(IDIR)/%.h)
|
||||
|
||||
CFLAGS = -I$(IDIR)
|
||||
CFLAGS += -Wall -Wextra -Werror
|
||||
CFLAGS += -Wall -Wextra -Werror -g3
|
||||
|
||||
SRCS = \
|
||||
ft_bzero.c \
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/25 14:45:53 by hulamy #+# #+# */
|
||||
/* Updated: 2022/05/04 16:04:03 by hulamy ### ########.fr */
|
||||
/* Updated: 2022/05/04 18:18:01 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -28,7 +28,7 @@ void ft_putchar_fd(char c, int fd);
|
||||
void ft_putstr_fd(char *s, int fd);
|
||||
void ft_putnbr_fd(int n, int fd);
|
||||
|
||||
typedef struct s_list
|
||||
typedef struct s_list
|
||||
{
|
||||
void *content;
|
||||
struct s_list *prev;
|
||||
@@ -37,14 +37,14 @@ typedef struct s_list
|
||||
|
||||
t_list *ft_lstcreate(void *content);
|
||||
void *ft_lstpush_back(t_list **lst, t_list *new);
|
||||
t_list *ft_lstfind(t_list *lst, void *to_find, int (*comp)(void*, void *));
|
||||
t_list *ft_lstfind(t_list *lst, void *to_find,
|
||||
int (*comp)(void*, void *));
|
||||
void ft_lsterase(t_list *lst, void (*del)(void *));
|
||||
void ft_lstfree(t_list *lst, void (*del)(void *));
|
||||
int ft_strcmp(const char *s1, const char *s2);
|
||||
void *ft_memalloc(size_t size);
|
||||
int ft_abs(int n);
|
||||
int ft_sign(int i);
|
||||
|
||||
int ft_arrint(int * intarr, int comp, size_t size);
|
||||
int ft_arrint(int *intarr, int comp, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/12/12 22:41:54 by hulamy #+# #+# */
|
||||
/* Updated: 2022/05/04 14:11:07 by pblagoje ### ########.fr */
|
||||
/* Created: 2022/05/04 18:15:10 by hulamy #+# #+# */
|
||||
/* Updated: 2022/05/04 18:35:56 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,25 +15,25 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** #include <stdio.h>
|
||||
** #include <stdlib.h>
|
||||
** #include <unistd.h>
|
||||
**
|
||||
** #include <stdio.h>
|
||||
**
|
||||
** size_t ft_strlen(const char *str)
|
||||
** {
|
||||
** size_t i;
|
||||
**
|
||||
**
|
||||
** i = 0;
|
||||
** while (str[i])
|
||||
** i++;
|
||||
** return (i);
|
||||
** }
|
||||
**
|
||||
**
|
||||
** char *ft_substr(char const *s, unsigned int start, size_t len)
|
||||
** {
|
||||
** char *str;
|
||||
** size_t i;
|
||||
**
|
||||
**
|
||||
** if (!s)
|
||||
** return (NULL);
|
||||
** if (ft_strlen(s) < start)
|
||||
@@ -46,29 +46,30 @@
|
||||
** str[i] = '\0';
|
||||
** return (str);
|
||||
** }
|
||||
**
|
||||
**
|
||||
** char **ft_split(char const *s, char c);
|
||||
** char **ft_strsplit(char const *s, char c);
|
||||
**
|
||||
**
|
||||
** int main(void)
|
||||
** {
|
||||
** char **str;
|
||||
** int i;
|
||||
**
|
||||
**
|
||||
** char *s;
|
||||
** char c;
|
||||
**
|
||||
**
|
||||
** i = -1;
|
||||
** s = NULL;
|
||||
** // s = NULL;
|
||||
** s = "hello les amis :)";
|
||||
** c = ' ';
|
||||
** str = ft_split(s, c);
|
||||
** //if (str)
|
||||
** //{
|
||||
** printf("s : '%s'\n", s);
|
||||
** printf("*str : '%p'\n", str[0]);
|
||||
** while (str[++i])
|
||||
** printf("str[%i] : '%s'\n", i, str[i]);
|
||||
** //}
|
||||
** printf("s : '%s'\n", s);
|
||||
** printf("*str : '%p'\n", str[0]);
|
||||
** while (str[++i])
|
||||
** printf("str[%i] : '%s'\n", i, str[i]);
|
||||
** while (str[--i])
|
||||
** free(str[i]);
|
||||
** free(str);
|
||||
** return (0);
|
||||
** }
|
||||
*/
|
||||
@@ -89,7 +90,7 @@ static int count(char const *s, char c)
|
||||
return (words);
|
||||
}
|
||||
|
||||
void *ft_free(char **array, int w)
|
||||
void *free_array(char **array, int w)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -109,6 +110,14 @@ char **empty_s(char **empty)
|
||||
return (empty);
|
||||
}
|
||||
|
||||
static int copy_portion(char **array, char const *s, int len)
|
||||
{
|
||||
*array = ft_substr(s, 0, len);
|
||||
if (!(*array))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
char **ft_split(char const *s, char c)
|
||||
{
|
||||
char **array;
|
||||
@@ -128,8 +137,8 @@ char **ft_split(char const *s, char c)
|
||||
{
|
||||
while (s[len] != '\0' && s[len] != c)
|
||||
len++;
|
||||
if (!(array[w++] = ft_substr(s, 0, len)))
|
||||
return (ft_free(array, w));
|
||||
if (!copy_portion(&array[w++], s, len))
|
||||
return (free_array(array, w));
|
||||
s += len - 1;
|
||||
}
|
||||
s++;
|
||||
|
||||
Reference in New Issue
Block a user