core: Use JS_NewTypedArray.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m29s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m29s
This commit is contained in:
@ -500,11 +500,13 @@ void tf_util_document_settings(const char* line_prefix)
|
||||
JSValue tf_util_new_uint8_array(JSContext* context, const uint8_t* data, size_t size)
|
||||
{
|
||||
JSValue array_buffer = JS_NewArrayBufferCopy(context, data, size);
|
||||
JSValue global = JS_GetGlobalObject(context);
|
||||
JSValue constructor = JS_GetPropertyStr(context, global, "Uint8Array");
|
||||
JSValue result = JS_CallConstructor(context, constructor, 1, &array_buffer);
|
||||
JS_FreeValue(context, constructor);
|
||||
JS_FreeValue(context, global);
|
||||
JSValue args[] =
|
||||
{
|
||||
array_buffer,
|
||||
JS_NewInt64(context, 0),
|
||||
JS_NewInt64(context, size),
|
||||
};
|
||||
JSValue result = JS_NewTypedArray(context, tf_countof(args), args, JS_TYPED_ARRAY_UINT8C);
|
||||
JS_FreeValue(context, array_buffer);
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user