typed_array_get_data


Description:

[ Version ( since = "2.38" ) ]
public void* typed_array_get_data (out size_t length)

Obtains a pointer to the memory region that holds the elements of the typed array; modifications done to them will be visible to JavaScript code.

If length is not null, the number of elements contained in the typed array are also stored in the pointed location.

The returned pointer needs to be casted to the appropriate type (see TypedArrayType), and has the `offset` over the underlying array buffer data applied—that is, points to the first element of the typed array:

if (jsc_value_typed_array_get_type(value) != JSC_TYPED_ARRAY_UINT32)
g_error ("Only arrays of uint32_t are supported");

gsize count = 0;
uint32_t *elements = jsc_value_typed_array_get_contents (value, &count);
for (gsize i = 0; i < count; i++)
g_print ("index %zu, value %" PRIu32 "\n", i, elements[i]);

Note that the pointer returned by this function is not guaranteed to remain the same after calls to other JSC API functions. See array_buffer_get_data for details.

Parameters:

this

a Value

length

location to return the number of elements contained

Returns:

pointer to memory.