]> Dogcows Code - chaz/yoink/blob - yajl/src/yajl/yajl_common.h
minor cleanups
[chaz/yoink] / yajl / src / yajl / yajl_common.h
1 /*
2 * Copyright 2007-2009, Lloyd Hilaiel.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
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
14 * distribution.
15 *
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.
19 *
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.
31 */
32
33 #ifndef __YAJL_COMMON_H__
34 #define __YAJL_COMMON_H__
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 #define YAJL_MAX_DEPTH 128
41
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)
46 # ifdef YAJL_BUILD
47 # define YAJL_API __declspec(dllexport)
48 # else
49 # define YAJL_API __declspec(dllimport)
50 # endif
51 #else
52 # define YAJL_API
53 #endif
54
55 /** pointer to a malloc function, supporting client overriding memory
56 * allocation routines */
57 typedef void * (*yajl_malloc_func)(void *ctx, unsigned int sz);
58
59 /** pointer to a free function, supporting client overriding memory
60 * allocation routines */
61 typedef void (*yajl_free_func)(void *ctx, void * ptr);
62
63 /** pointer to a realloc function which can resize an allocation. */
64 typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, unsigned int sz);
65
66 /** A structure which can be passed to yajl_*_alloc routines to allow the
67 * client to specify memory allocation functions to be used. */
68 typedef struct
69 {
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 */
76 yajl_free_func free;
77 /** a context pointer that will be passed to above allocation routines */
78 void * ctx;
79 } yajl_alloc_funcs;
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif
This page took 0.032174 seconds and 4 git commands to generate.