aboutsummaryrefslogtreecommitdiff
path: root/include/buffer.h
blob: 57efe9e28e6fb48fb3b7a8866881c9ff7b5ad704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef AMALGAM_BUFFER_H
#define AMALGAM_BUFFER_H

#include "types.h"
#include "misc.h"

#define BUFFER_OK 0
#define BUFFER_ALLOC_FAIL -1

typedef struct {
    char* data;
    usize size;
    usize capacity;
} Buffer;

void buffer_init(Buffer *self);
void buffer_deinit(Buffer *self);

WARN_UNUSED_RESULT int buffer_append(Buffer *self, void *data, usize size);
void* buffer_get(Buffer *self, usize index, usize type_size);

#endif