name: duk_realloc_raw proto: | void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_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.
Reallocation 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.
If allocated size is extended from previous allocation, the newly allocated
bytes are not automatically zeroed and may contain arbitrary garbage.
The exact behavior depends on the ptr
and size
arguments as follows:
ptr
is non-NULL
and size
is greater
than zero, previous allocation is resized.ptr
is non-NULL
and size
is zero,
the call is equivalent to a
duk_free_raw()
.ptr
is NULL
, and size
is greater than
zero, the call is equivalent to a
duk_alloc_raw()
.ptr
is NULL
, and size
is zero, the
call is equivalent to a
duk_alloc_raw()
with a zero
size argument; the call may return NULL
or some other value
which is safe to give to
duk_free_raw()
.Memory reallocated with duk_realloc_raw()
can be freed with either
duk_free()
or
duk_free_raw()
.