You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
780 B

=proto
void *duk_realloc(duk_context *ctx, void *ptr, size_t size);
=summary
<p>Like <code><a href="#duk_realloc_raw">duk_realloc_raw()</a></code> but may
trigger a garbage collection to satisfy the request. However, the
allocated memory itself is not automatically garbage collected.</p>
<p>Memory reallocated with <code>duk_realloc()</code> can be freed with either
<code><a href="#duk_free">duk_free()</a></code> or
<code><a href="#duk_free_raw">duk_free_raw()</a></code>.</p>
=example
void *buf = duk_alloc(ctx, 1024);
if (buf) {
void *buf2 = duk_realloc(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_raw