name: duk_alloc_raw proto: | void *duk_alloc_raw(duk_context *ctx, duk_size_t size); summary: |

Allocate size bytes using the raw allocation function registered to the context. If allocation fails, returns NULL. If size is zero, the call may either return a NULL or some non-NULL value which may be safely given to e.g. duk_free_raw(). The allocation cannot trigger a garbage collection, and the allocated memory is not automatically garbage collected. The allocated memory is not automatically zeroed, and may contain arbitrary garbage.

Memory allocated with duk_alloc_raw() can be freed with either duk_free() or duk_free_raw().

example: | void *buf = duk_alloc_raw(ctx, 1024); if (buf) { printf("allocation successful: %p\n", buf); } else { printf("allocation failed\n"); } tags: - memory seealso: - duk_alloc introduced: 1.0.0