-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbytebuf.h
More file actions
37 lines (29 loc) · 848 Bytes
/
bytebuf.h
File metadata and controls
37 lines (29 loc) · 848 Bytes
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
#ifndef BYTEBUF
#define BYTEBUF
#define BYTEBUF_COOKIE 0xa6e59014
#define BYTEBUF_ARRAY_COOKIE 0xd80e50c6
// uninterpreted, unverified, unknown blob of bytes that may or may not be
// valid utf8
struct bytebuf
{
uint32_t cookie;
uint8_t *buf;
size_t len;
};
int bytebuf_init(struct bytebuf* byteb, uint8_t *ptr, size_t len);
void bytebuf_free(struct bytebuf* byteb);
// array of bytebuf
struct bytebuf_array
{
uint32_t cookie;
struct bytebuf* list;
size_t len;
size_t max;
};
int bytebuf_array_init(struct bytebuf_array* bba, size_t len);
void bytebuf_array_free(struct bytebuf_array* list);
void bytebuf_array_verify(struct bytebuf_array* bba);
int bytebuf_array_emplace_back(struct bytebuf_array* bba, uint8_t* ptr, size_t len);
#define bytebuf_array_for_each(bba, pbb) \
for(pbb=bba.list ; pbb<&bba.list[bba.len] ; pbb++)
#endif