MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxArrayBuffer

Function fxArrayBuffer

xs/sources/xsDataView.c:88–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86};
87
88void *fxArrayBuffer(txMachine* the, txSlot* slot, void* data, txInteger byteLength, txInteger maxByteLength)
89{
90 txSlot* instance;
91 txSlot* arrayBuffer;
92 txSlot* bufferInfo;
93 if (byteLength < 0)
94 mxRangeError("invalid byteLength %ld", byteLength);
95 mxPush(mxArrayBufferPrototype);
96 instance = fxNewArrayBufferInstance(the);
97 arrayBuffer = instance->next;
98 arrayBuffer->value.arrayBuffer.address = fxNewChunk(the, byteLength);
99 bufferInfo = arrayBuffer->next;
100 bufferInfo->value.bufferInfo.length = byteLength;
101 bufferInfo->value.bufferInfo.maxLength = maxByteLength;
102 if (data != NULL)
103 c_memcpy(arrayBuffer->value.arrayBuffer.address, data, byteLength);
104 else
105 c_memset(arrayBuffer->value.arrayBuffer.address, 0, byteLength);
106 mxPullSlot(slot);
107 return arrayBuffer->value.arrayBuffer.address;
108}
109
110void fxGetArrayBufferData(txMachine* the, txSlot* slot, txInteger byteOffset, void* data, txInteger byteLength)
111{

Callers 2

xsffi.cFile · 0.85
fxNormalizeStringFunction · 0.85

Calls 2

fxNewArrayBufferInstanceFunction · 0.85
fxNewChunkFunction · 0.85

Tested by

no test coverage detected