File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 38
38
39
39
#define YAJL_BUF_INIT_SIZE 2048
40
40
41
- typedef enum {
42
- yajl_buf_ok = 0 ,
43
- yajl_buf_alloc_failed ,
44
- yajl_buf_overflow
45
- } yajl_buf_state ;
46
-
47
41
struct yajl_buf_t {
48
42
yajl_buf_state state ;
49
43
unsigned int len ;
@@ -59,6 +53,12 @@ static struct yajl_buf_t buf_alloc_error = {
59
53
60
54
#include <stdio.h>
61
55
56
+ yajl_buf_state yajl_buf_err (yajl_buf buf )
57
+ {
58
+ assert (buf );
59
+ return buf -> state ;
60
+ }
61
+
62
62
static
63
63
yajl_buf_state yajl_buf_set_error (yajl_buf buf , yajl_buf_state err )
64
64
{
@@ -161,17 +161,22 @@ void yajl_buf_clear(yajl_buf buf)
161
161
162
162
const unsigned char * yajl_buf_data (yajl_buf buf )
163
163
{
164
+ assert (buf );
165
+ assert (!yajl_buf_err (buf ));
164
166
return buf -> data ;
165
167
}
166
168
167
169
unsigned int yajl_buf_len (yajl_buf buf )
168
170
{
171
+ assert (buf );
172
+ assert (!yajl_buf_err (buf ));
169
173
return buf -> used ;
170
174
}
171
175
172
176
void
173
177
yajl_buf_truncate (yajl_buf buf , unsigned int len )
174
178
{
179
+ assert (buf );
175
180
assert (len <= buf -> used );
176
181
buf -> used = len ;
177
182
}
Original file line number Diff line number Diff line change 43
43
* call overhead. YMMV.
44
44
*/
45
45
46
+ typedef enum {
47
+ yajl_buf_ok = 0 ,
48
+ yajl_buf_alloc_failed ,
49
+ yajl_buf_overflow
50
+ } yajl_buf_state ;
51
+
46
52
/**
47
53
* yajl_buf is a buffer with exponential growth. the buffer ensures that
48
54
* you are always null padded.
@@ -77,4 +83,7 @@ unsigned int yajl_buf_len(yajl_buf buf);
77
83
YAJL_API
78
84
void yajl_buf_truncate (yajl_buf buf , unsigned int len );
79
85
86
+ /* get the state of buffer */
87
+ yajl_buf_state yajl_buf_err (yajl_buf buf );
88
+
80
89
#endif
You can’t perform that action at this time.
0 commit comments