-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathzwbytes.h
60 lines (50 loc) · 1.39 KB
/
zwbytes.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef ZWBYTES_H
#define ZWBYTES_H
#include <stdint.h>
#ifdef __cplusplus
#include <string>
#include <vector>
extern "C" {
#endif
/**
* zwbytes_t is a container for byte arrays.
*/
typedef struct {
uint8_t* data;
size_t size;
} zwbytes_t;
/**
* zwbytes_new creates and returns a new, empty zwbytes_t object. Make sure to
* destroy it when finished with zwbytes_free.
* @return An empty zwbytes_t object.
*/
zwbytes_t* zwbytes_new();
/**
* zwbytes_reserve resizes the zwbytes_t, if necessary, to the new size.
* @param bytes The zwbytes_t object to operate on.
* @param size The new size.
*/
void zwbytes_reserve(zwbytes_t *bytes, size_t size);
/**
* zwbytes_set sets the value of the byte at the given position.
* @param bytes The zwbytes_t object to operate on.
* @param pos The position of the byte to set.
* @param val The byte value to set.
*/
void zwbytes_set(zwbytes_t *bytes, size_t pos, uint8_t val);
/**
* zwbytes_at returns the value of the byte at the given position.
* @param bytes The zwbytes_t object to operate on.
* @param pos The position of the byte to get.
* @return The value of the byte.
*/
uint8_t zwbytes_at(zwbytes_t *bytes, size_t pos);
/**
* zwbytes_free frees the zwbytes_t object.
* @param list The zwbytes_t object to free.
*/
void zwbytes_free(zwbytes_t *bytes);
#ifdef __cplusplus
} // end extern "C"
#endif
#endif // define ZWBYTES_H