"Fossies" - the Fresh Open Source Software Archive

Member "yajl-2.1.0/src/yajl_buf.h" (19 Mar 2014, 1859 Bytes) of package /linux/www/yajl-2.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "yajl_buf.h" see the Fossies "Dox" file reference documentation.

    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 "api/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 /* allocate a new buffer */
   37 yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc);
   38 
   39 /* free the buffer */
   40 void yajl_buf_free(yajl_buf buf);
   41 
   42 /* append a number of bytes to the buffer */
   43 void yajl_buf_append(yajl_buf buf, const void * data, size_t len);
   44 
   45 /* empty the buffer */
   46 void yajl_buf_clear(yajl_buf buf);
   47 
   48 /* get a pointer to the beginning of the buffer */
   49 const unsigned char * yajl_buf_data(yajl_buf buf);
   50 
   51 /* get the length of the buffer */
   52 size_t yajl_buf_len(yajl_buf buf);
   53 
   54 /* truncate the buffer */
   55 void yajl_buf_truncate(yajl_buf buf, size_t len);
   56 
   57 #endif