minishell/src/buffer/buffer_charptr.c

31 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* buffer_charptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/10 18:45:49 by kcolin #+# #+# */
/* Updated: 2025/03/10 18:46:35 by kcolin ### ########.fr */
/* */
/* ************************************************************************** */
#include "buffer.h"
#include <stdlib.h>
/*
** Free this buffer, but return a pointer to the internal string, which is not
** freed.
**
** If buffer is null, return null.
*/
char *ft_buffer_to_charptr(t_buffer *buffer)
{
char *out;
if (buffer == NULL)
return (NULL);
out = buffer->buffer;
free(buffer);
return (out);
}