mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
44 lines
1.5 KiB
C
44 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* worddesc.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/02/13 17:20:36 by khais #+# #+# */
|
|
/* Updated: 2025/02/14 15:23:44 by khais ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "worddesc.h"
|
|
#include "libft.h"
|
|
#include <stdlib.h>
|
|
|
|
/*
|
|
** allocate a new worddesc with zeroed flags and the given word as word.
|
|
**
|
|
** return null in case of error, or if word is null
|
|
*/
|
|
t_worddesc *worddesc_create(char *word)
|
|
{
|
|
t_worddesc *retvalue;
|
|
|
|
if (word == NULL)
|
|
return (NULL);
|
|
retvalue = ft_calloc(1, sizeof(t_worddesc));
|
|
if (retvalue == NULL)
|
|
return (NULL);
|
|
retvalue->word = word;
|
|
return (retvalue);
|
|
}
|
|
|
|
/*
|
|
** free all memory associated with this worddesc
|
|
*/
|
|
void worddesc_destroy(t_worddesc *worddesc)
|
|
{
|
|
if (worddesc == NULL)
|
|
return ;
|
|
free(worddesc->word);
|
|
free(worddesc);
|
|
}
|