mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
buffer: add ft_buffer_to_charptr function
This commit is contained in:
parent
cae2dfe4d6
commit
0486368a07
4 changed files with 36 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/12 12:39:58 by kcolin #+# #+# */
|
||||
/* Updated: 2025/02/14 18:19:49 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/10 18:45:34 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/12 12:35:28 by kcolin #+# #+# */
|
||||
/* Updated: 2025/02/14 18:20:08 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/10 18:45:44 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -41,5 +41,7 @@ t_buffer *ft_buffer_new(void);
|
|||
void ft_buffer_free(t_buffer *buffer);
|
||||
t_buffer *ft_buffer_pushchar(t_buffer *buffer, char c);
|
||||
t_buffer *ft_buffer_push_buf(t_buffer *buffer, char *buf, size_t n);
|
||||
// buffer_charptr.c
|
||||
char *ft_buffer_to_charptr(t_buffer *buffer);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
31
src/buffer/buffer_charptr.c
Normal file
31
src/buffer/buffer_charptr.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* buffer_charptr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/10 18:45:49 by khais #+# #+# */
|
||||
/* Updated: 2025/03/10 18:46:35 by khais ### ########.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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue