=proto void *duk_to_buffer(duk_context *ctx, duk_idx_t index, duk_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; duk_size_t sz; ptr = duk_to_buffer(ctx, -3, &sz); printf("coerced data at %p, size %lu\n", ptr, (unsigned long) sz); =tags stack buffer =seealso duk_to_fixed_buffer duk_to_dynamic_buffer