-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_buffer.c
30 lines (27 loc) · 1.21 KB
/
ft_buffer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_buffer.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvarodi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/14 00:35:31 by vvarodi #+# #+# */
/* Updated: 2020/08/14 00:40:49 by vvarodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
void write_and_clear(t_buffer *b)
{
b->written += b->buff_i;
write(1, b->buffer, BUFFER_SIZE);
ft_bzero(b->buffer, sizeof(b->buffer));
b->buff_i = 0;
}
void add_to_buffer(t_buffer *b, t_flags *f, char c)
{
if (b->buff_i == BUFFER_SIZE)
write_and_clear(b);
b->buffer[b->buff_i] = c;
b->buff_i++;
f->width--;
}