-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffer.h
47 lines (30 loc) · 1.08 KB
/
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
46
47
#ifndef _AISL_BUFFER_H_
#define _AISL_BUFFER_H_
#include <stdint.h>
struct _buffer_t
{
char *data;
uint32_t size;
uint32_t len;
};
typedef struct _buffer_t * buffer_t;
/* constructor -------------------------------------------------------------- */
buffer_t
buffer_new(uint32_t size);
/* destructor --------------------------------------------------------------- */
void
buffer_free(buffer_t self);
/* set buffer data and size ------------------------------------------------- */
void
buffer_set(buffer_t self, const char * data, uint32_t d_len);
/* move data from one buffer to another ------------------------------------- */
void
buffer_move(buffer_t target, buffer_t source);
/* put data to buffer without resizing, returns size of moved data ---------- */
uint32_t
buffer_put(buffer_t source, const char * data, uint32_t d_len);
/* add data to buffer with resizing if it is necessary ---------------------- */
void
buffer_add(buffer_t source, const char * data, uint32_t d_len);
/* -------------------------------------------------------------------------- */
#endif