=proto void *duk_get_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size); =stack [ ... val! ... ] =summary

Get the data pointer for a buffer value at index without modifying or coercing the value. Returns a non-NULL pointer if the value is a valid buffer (fixed or dynamic) with a non-zero size. For a zero-size buffer, may return a NULL or a non-NULL pointer. Returns NULL if the value is not a buffer or the index is invalid. If out_size is non-NULL, the size of the buffer is written to *out_size; 0 is written if the return value is NULL.

There is no reliable way to distinguish a zero-size buffer from a non-buffer based on the return values. A NULL with zero size is returned for a non-buffer. The same values may be returned for a zero-size buffer (although it is also possible that a non-NULL pointer is returned).
=example void *ptr; duk_size_t sz; ptr = duk_get_buffer(ctx, &sz); printf("buf=%p, size=%lu\n", ptr, (unsigned long) sz); =tags stack buffer