]> git.proxmox.com Git - ceph.git/blame - ceph/src/civetweb/src/third_party/duktape-1.8.0/src-separate/duk_alloc_default.c
buildsys: switch source download to quincy
[ceph.git] / ceph / src / civetweb / src / third_party / duktape-1.8.0 / src-separate / duk_alloc_default.c
CommitLineData
7c673cae
FG
1/*
2 * Default allocation functions.
3 *
4 * Assumes behavior such as malloc allowing zero size, yielding
5 * a NULL or a unique pointer which is a no-op for free.
6 */
7
8#include "duk_internal.h"
9
11fdf7f2 10#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)
7c673cae
FG
11DUK_INTERNAL void *duk_default_alloc_function(void *udata, duk_size_t size) {
12 void *res;
13 DUK_UNREF(udata);
14 res = DUK_ANSI_MALLOC(size);
15 DUK_DDD(DUK_DDDPRINT("default alloc function: %lu -> %p",
16 (unsigned long) size, (void *) res));
17 return res;
18}
19
20DUK_INTERNAL void *duk_default_realloc_function(void *udata, void *ptr, duk_size_t newsize) {
21 void *res;
22 DUK_UNREF(udata);
23 res = DUK_ANSI_REALLOC(ptr, newsize);
24 DUK_DDD(DUK_DDDPRINT("default realloc function: %p %lu -> %p",
25 (void *) ptr, (unsigned long) newsize, (void *) res));
26 return res;
27}
28
29DUK_INTERNAL void duk_default_free_function(void *udata, void *ptr) {
30 DUK_DDD(DUK_DDDPRINT("default free function: %p", (void *) ptr));
31 DUK_UNREF(udata);
32 DUK_ANSI_FREE(ptr);
33}
11fdf7f2 34#endif /* DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS */