YAJL 1.0.12
yajl_common.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010, Lloyd Hilaiel.
00003  * 
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are
00006  * met:
00007  * 
00008  *  1. Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  * 
00011  *  2. Redistributions in binary form must reproduce the above copyright
00012  *     notice, this list of conditions and the following disclaimer in
00013  *     the documentation and/or other materials provided with the
00014  *     distribution.
00015  * 
00016  *  3. Neither the name of Lloyd Hilaiel nor the names of its
00017  *     contributors may be used to endorse or promote products derived
00018  *     from this software without specific prior written permission.
00019  * 
00020  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00021  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
00024  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00026  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00028  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00029  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  */ 
00032 
00033 #ifndef __YAJL_COMMON_H__
00034 #define __YAJL_COMMON_H__
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif    
00039 
00040 #define YAJL_MAX_DEPTH 128
00041 
00042 /* msft dll export gunk.  To build a DLL on windows, you
00043  * must define WIN32, YAJL_SHARED, and YAJL_BUILD.  To use a shared
00044  * DLL, you must define YAJL_SHARED and WIN32 */
00045 #if defined(WIN32) && defined(YAJL_SHARED)
00046 #  ifdef YAJL_BUILD
00047 #    define YAJL_API __declspec(dllexport)
00048 #  else
00049 #    define YAJL_API __declspec(dllimport)
00050 #  endif
00051 #else
00052 #  if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
00053 #    define YAJL_API __attribute__ ((visibility("default")))
00054 #  else
00055 #    define YAJL_API
00056 #  endif
00057 #endif 
00058 
00061 typedef void * (*yajl_malloc_func)(void *ctx, unsigned int sz);
00062 
00065 typedef void (*yajl_free_func)(void *ctx, void * ptr);
00066 
00068 typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, unsigned int sz);
00069 
00072 typedef struct
00073 {
00075     yajl_malloc_func malloc;
00077     yajl_realloc_func realloc;
00080     yajl_free_func free;
00082     void * ctx;
00083 } yajl_alloc_funcs;
00084 
00085 #ifdef __cplusplus
00086 }
00087 #endif    
00088 
00089 #endif