YAJL 2.0.0
yajl_common.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007-2011, Lloyd Hilaiel <lloyd@hilaiel.com>
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 #ifndef __YAJL_COMMON_H__
00018 #define __YAJL_COMMON_H__
00019 
00020 #include <stddef.h>
00021 
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif    
00025 
00026 #define YAJL_MAX_DEPTH 128
00027 
00028 /* msft dll export gunk.  To build a DLL on windows, you
00029  * must define WIN32, YAJL_SHARED, and YAJL_BUILD.  To use a shared
00030  * DLL, you must define YAJL_SHARED and WIN32 */
00031 #if defined(WIN32) && defined(YAJL_SHARED)
00032 #  ifdef YAJL_BUILD
00033 #    define YAJL_API __declspec(dllexport)
00034 #  else
00035 #    define YAJL_API __declspec(dllimport)
00036 #  endif
00037 #else
00038 #  if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
00039 #    define YAJL_API __attribute__ ((visibility("default")))
00040 #  else
00041 #    define YAJL_API
00042 #  endif
00043 #endif 
00044 
00047 typedef void * (*yajl_malloc_func)(void *ctx, size_t sz);
00048 
00051 typedef void (*yajl_free_func)(void *ctx, void * ptr);
00052 
00054 typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, size_t sz);
00055 
00058 typedef struct
00059 {
00061     yajl_malloc_func malloc;
00063     yajl_realloc_func realloc;
00066     yajl_free_func free;
00068     void * ctx;
00069 } yajl_alloc_funcs;
00070 
00071 #ifdef __cplusplus
00072 }
00073 #endif
00074 
00075 #endif