]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/jansson/memory.c
a2be5d23d8c96fc58569b8f616c100ab5f50e47d
2 * Copyright (c) 2009-2016 Petri Lehtinen <petri@digip.org>
3 * Copyright (c) 2011-2012 Basile Starynkevitch <basile@starynkevitch.net>
5 * Jansson is free software; you can redistribute it and/or modify it
6 * under the terms of the MIT license. See LICENSE for details.
13 #include "jansson_private.h"
15 /* C89 allows these to be macros */
19 /* memory function pointers */
20 static json_malloc_t do_malloc
= malloc
;
21 static json_free_t do_free
= free
;
23 void *jsonp_malloc(size_t size
)
28 return (*do_malloc
)(size
);
31 void jsonp_free(void *ptr
)
39 char *jsonp_strdup(const char *str
)
41 return jsonp_strndup(str
, strlen(str
));
44 char *jsonp_strndup(const char *str
, size_t len
)
48 new_str
= jsonp_malloc(len
+ 1);
52 memcpy(new_str
, str
, len
);
57 void json_set_alloc_funcs(json_malloc_t malloc_fn
, json_free_t free_fn
)
59 do_malloc
= malloc_fn
;
63 void json_get_alloc_funcs(json_malloc_t
*malloc_fn
, json_free_t
*free_fn
)
66 *malloc_fn
= do_malloc
;