=proto void *duk_to_buffer(duk_context *ctx, int index, size_t *out_size); =stack [ ... val! ... ] -> [ ... buffer(val)! ... ] =summary

Replace the value at index with a buffer-coerced value. Returns a pointer to the buffer data (may be NULL for a zero-size buffer), and writes the size of the buffer into *out_size (if out_size is non-NULL). If index is invalid, throws an error.

Coercion rules:

=example void *ptr; size_t sz; ptr = duk_to_buffer(ctx, -3, &sz); printf("coerced data at %p, size %u\n", ptr, (unsigned int) sz); =tags stack buffer