1    | /*
2    |  * Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
3    |  *
4    |  * Permission to use, copy, modify, and/or distribute this software for any
5    |  * purpose with or without fee is hereby granted, provided that the above
6    |  * copyright notice and this permission notice appear in all copies.
7    |  *
8    |  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9    |  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10   |  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11   |  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12   |  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13   |  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14   |  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15   |  */
16   | 
17   | #ifndef __YAJL_BUF_H__
18   | #define __YAJL_BUF_H__
19   | 
20   | #include "yajl/yajl_common.h"
21   | #include "yajl_alloc.h"
22   | 
23   | /*
24   |  * Implementation/performance notes.  If this were moved to a header
25   |  * only implementation using #define's where possible we might be
26   |  * able to sqeeze a little performance out of the guy by killing function
27   |  * call overhead.  YMMV.
28   |  */
29   | 
30   | /*+
31   |  * yajl_buf is a buffer with exponential growth.  the buffer ensures that
32   |  * you are always null padded.
33   |  +*/
34   | typedef struct yajl_buf_t * yajl_buf;
35   | 
36   | yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc);
37   | void yajl_buf_free(yajl_buf buf);
38   | void yajl_buf_append(yajl_buf buf, const void * data, size_t len);
39   | void yajl_buf_clear(yajl_buf buf);
40   | const unsigned char * yajl_buf_data(yajl_buf buf);
41   | size_t yajl_buf_len(yajl_buf buf);
42   | void yajl_buf_truncate(yajl_buf buf, size_t len);
43   | 
44   | #endif