-
Notifications
You must be signed in to change notification settings - Fork 2
/
string_buffer.h
45 lines (38 loc) · 1.69 KB
/
string_buffer.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* string_buffer.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jkong <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/21 15:37:17 by jkong #+# #+# */
/* Updated: 2022/06/25 13:24:27 by jkong ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef STRING_BUFFER_H
# define STRING_BUFFER_H
# include "safe_mem.h"
# include <stdlib.h>
# include <stdarg.h>
# ifndef INITIAL_CAPACITY
# define INITIAL_CAPACITY 0x20
# endif
# ifndef GROW_THRESHOLD
# define GROW_THRESHOLD 0x400
# endif
typedef struct s_str_buf
{
char *str;
size_t length;
size_t capacity;
} t_str_buf;
t_str_buf *str_append_raw(t_str_buf *buf, const char *s, size_t n);
t_str_buf *str_append(t_str_buf *buf, const char *s);
char *str_dispose(t_str_buf *buf);
t_str_buf *str_append_number(t_str_buf *buf, int n);
t_str_buf *str_append_character(t_str_buf *buf, char c);
t_str_buf *str_append_nullable(t_str_buf *buf, char *s, char *def);
t_str_buf *str_append_format(t_str_buf *buf, const char *format, ...);
t_str_buf *str_append_format_v(t_str_buf *buf, const char *format,
va_list *ap);
#endif