line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#ifndef _XH_BUFFER_H_ |
2
|
|
|
|
|
|
|
#define _XH_BUFFER_H_ |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#include "xh_config.h" |
5
|
|
|
|
|
|
|
#include "xh_core.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
typedef struct _xh_buffer_t xh_buffer_t; |
8
|
|
|
|
|
|
|
struct _xh_buffer_t { |
9
|
|
|
|
|
|
|
xh_char_t *start; |
10
|
|
|
|
|
|
|
xh_char_t *cur; |
11
|
|
|
|
|
|
|
xh_char_t *end; |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
void xh_buffer_init(xh_buffer_t *buf, size_t size); |
15
|
|
|
|
|
|
|
void xh_buffer_grow(xh_buffer_t *buf, size_t inc); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
XH_INLINE void |
18
|
16
|
|
|
|
|
|
xh_buffer_destroy(xh_buffer_t *buf) |
19
|
|
|
|
|
|
|
{ |
20
|
16
|
50
|
|
|
|
|
if (buf->start != NULL) { |
21
|
|
|
|
|
|
|
xh_log_debug1("free enc buf: %p", buf->start); |
22
|
0
|
|
|
|
|
|
free(buf->start); |
23
|
|
|
|
|
|
|
} |
24
|
16
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#define xh_buffer_avail(b) ((b)->end - (b)->cur) |
27
|
|
|
|
|
|
|
#define xh_buffer_start(b) ((b)->start) |
28
|
|
|
|
|
|
|
#define xh_buffer_pos(b) ((b)->cur) |
29
|
|
|
|
|
|
|
#define xh_buffer_end(b) ((b)->end) |
30
|
|
|
|
|
|
|
#define xh_buffer_size(b) ((b)->end - (b)->start) |
31
|
|
|
|
|
|
|
#define xh_buffer_seek(b, p) (b)->cur = p |
32
|
|
|
|
|
|
|
#define xh_buffer_seek_eof(b) (b)->cur = (b)->end |
33
|
|
|
|
|
|
|
#define xh_buffer_seek_top(b) (b)->cur = (b)->start |
34
|
|
|
|
|
|
|
#define xh_buffer_grow50(b) xh_buffer_grow((b), xh_buffer_size(b) / 2) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#endif /* _XH_BUFFER_H_ */ |