worddesc_create: take the marker as an argument

This commit is contained in:
Khaïs COLIN 2025-03-06 15:06:31 +01:00
parent 14dbabd6ea
commit e99c7e5986
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
2 changed files with 10 additions and 13 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 17:20:36 by khais #+# #+# */
/* Updated: 2025/03/06 15:03:56 by khais ### ########.fr */
/* Updated: 2025/03/06 16:52:44 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,7 @@
#include <stdlib.h>
/*
** allocate a new worddesc with given flags and the given word as word.
** allocate a new worddesc with given flags, marker, and word.
**
** return null in case of error, or if word is null
**
@ -25,7 +25,7 @@
** In case of allocation error, word is freed, as well as any memory allocated
** in this function
*/
t_worddesc *worddesc_create(char *word, char flags)
t_worddesc *worddesc_create(char *word, char flags, char *marker)
{
t_worddesc *retvalue;
@ -36,10 +36,7 @@ t_worddesc *worddesc_create(char *word, char flags)
return (free(word), NULL);
retvalue->word = word;
retvalue->flags = flags;
retvalue->marker = ft_calloc(ft_strlen(word) + 1, sizeof(char));
if (retvalue->marker == NULL)
return (free(word), free(retvalue), NULL);
ft_memset(retvalue->marker, ' ', ft_strlen(word));
retvalue->marker = marker;
return (retvalue);
}

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:47:58 by khais #+# #+# */
/* Updated: 2025/03/06 17:20:50 by khais ### ########.fr */
/* Updated: 2025/03/06 17:21:07 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -55,7 +55,7 @@ typedef struct s_worddesc
char *marker;
} t_worddesc;
t_worddesc *worddesc_create(char *word, char flags);
t_worddesc *worddesc_create(char *word, char flags, char *marker);
void worddesc_destroy(t_worddesc *worddesc);
#endif