name: duk_to_pointer proto: | void *duk_to_pointer(duk_context *ctx, duk_idx_t idx); stack: | [ ... val! ... ] -> [ ... pointer(val)! ... ] summary: |

Replaces the value at idx with a pointer-coerced value. Returns the resulting void * value. If idx is invalid, throws an error.

Coercion rules:

This API call is really only useful for debugging. Note in particular that the pointer returned must not be accessed, as it points to an internal heap header. This is the case even for string/buffer values: the returned pointer differs from the one returned by duk_get_string() and duk_get_buffer().
example: | /* Don't dereference the pointer. */ printf("coerced pointer: %p\n", duk_to_pointer(ctx, -3)); tags: - stack introduced: 1.0.0