=proto void *duk_realloc_raw(duk_context *ctx, void *ptr, size_t size); =summary

Resize a previous allocation made with the allocation functions registered to the context. The ptr argument points to the previous allocation while size is the new allocation size. The call returns a pointer to the new allocation which may have a different pointer than the previous one. If the reallocation fails, a NULL is returned and the previous allocation is still valid. Relocation failure should only be possible when the new size is larger than the previous size (i.e. caller tries to grow the allocation). The attempt to reallocate cannot trigger a garbage collection, and the allocated memory is not automatically garbage collected.

The exact behavior depends on the ptr and size arguments as follows:

Memory reallocated with duk_realloc_raw() can be freed with either duk_free() or duk_free_raw().

=example void *buf = duk_alloc_raw(ctx, 1024); if (buf) { void *buf2 = duk_realloc_raw(ctx, 2048); if (!buf2) { printf("failed to reallocate, 'buf' still valid\n"); } else { printf("reallocate successful, 'buf2' now valid\n"); } } =tags memory =seealso duk_realloc