Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duktape-1.5.2/src-separate/duk_alloc_default.c
Go to the documentation of this file.
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
10#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)
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}
34#endif /* DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS */
DUK_INTERNAL void duk_default_free_function(void *udata, void *ptr)
DUK_INTERNAL void * duk_default_alloc_function(void *udata, duk_size_t size)
DUK_INTERNAL void * duk_default_realloc_function(void *udata, void *ptr, duk_size_t newsize)