Browse Source

Fix conditionality for default alloc providers

pull/695/head
Sami Vaarala 9 years ago
parent
commit
6ff6896952
  1. 2
      src/duk_alloc_default.c
  2. 5
      src/duk_api_heap.c

2
src/duk_alloc_default.c

@ -7,6 +7,7 @@
#include "duk_internal.h"
#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)
DUK_INTERNAL void *duk_default_alloc_function(void *udata, duk_size_t size) {
void *res;
DUK_UNREF(udata);
@ -30,3 +31,4 @@ DUK_INTERNAL void duk_default_free_function(void *udata, void *ptr) {
DUK_UNREF(udata);
DUK_ANSI_FREE(ptr);
}
#endif /* DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS */

5
src/duk_api_heap.c

@ -24,9 +24,14 @@ duk_context *duk_create_heap(duk_alloc_function alloc_func,
if (!alloc_func) {
DUK_ASSERT(realloc_func == NULL);
DUK_ASSERT(free_func == NULL);
#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)
alloc_func = duk_default_alloc_function;
realloc_func = duk_default_realloc_function;
free_func = duk_default_free_function;
#else
DUK_D(DUK_DPRINT("no allocation functions given and no default providers"));
return NULL;
#endif
} else {
DUK_ASSERT(realloc_func != NULL);
DUK_ASSERT(free_func != NULL);

Loading…
Cancel
Save