summaryrefslogtreecommitdiff
path: root/src/buffer.h
blob: 67e1bf77998203cc3e407a834e5822ba18ae8427 (plain)
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
#ifndef BUFFER_H
#define BUFFER_H
#include <stddef.h>

#define GROW_SIZE 10

typedef struct {
    char *content;
    size_t used;
    size_t size;
} growable_buffer;

bool init_growable_buffer(growable_buffer *buffer);
char *grow_growable_buffer(growable_buffer *buffer, size_t at_least);
void append_growable_buffer(growable_buffer *buffer, char* content, size_t length);
void free_growable_buffer(growable_buffer *buffer);


typedef struct {
    char *content;
    size_t size;
} fixed_buffer;

bool init_fixed_buffer(fixed_buffer *buffer, char *orig);
void free_fixed_buffer(fixed_buffer *buffer);

#endif // BUFFER_H