2 * Copyright 2007-2009, Lloyd Hilaiel.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef __YAJL_COMMON_H__
34 #define __YAJL_COMMON_H__
40 #define YAJL_MAX_DEPTH 128
42 /* msft dll export gunk. To build a DLL on windows, you
43 * must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared
44 * DLL, you must define YAJL_SHARED and WIN32 */
45 #if defined(WIN32) && defined(YAJL_SHARED)
47 # define YAJL_API __declspec(dllexport)
49 # define YAJL_API __declspec(dllimport)
55 /** pointer to a malloc function, supporting client overriding memory
56 * allocation routines */
57 typedef void * (*yajl_malloc_func
)(void *ctx
, unsigned int sz
);
59 /** pointer to a free function, supporting client overriding memory
60 * allocation routines */
61 typedef void (*yajl_free_func
)(void *ctx
, void * ptr
);
63 /** pointer to a realloc function which can resize an allocation. */
64 typedef void * (*yajl_realloc_func
)(void *ctx
, void * ptr
, unsigned int sz
);
66 /** A structure which can be passed to yajl_*_alloc routines to allow the
67 * client to specify memory allocation functions to be used. */
70 /** pointer to a function that can allocate uninitialized memory */
71 yajl_malloc_func malloc
;
72 /** pointer to a function that can resize memory allocations */
73 yajl_realloc_func realloc
;
74 /** pointer to a function that can free memory allocated using
75 * reallocFunction or mallocFunction */
77 /** a context pointer that will be passed to above allocation routines */