| 150 | } |
| 151 | |
| 152 | void fxSetArrayBufferLength(txMachine* the, txSlot* slot, txInteger target) |
| 153 | { |
| 154 | txSlot* instance = fxCheckArrayBufferInstance(the, slot); |
| 155 | txSlot* arrayBuffer = instance->next; |
| 156 | txSlot* bufferInfo = arrayBuffer->next; |
| 157 | txInteger length = bufferInfo->value.bufferInfo.length; |
| 158 | txByte* address = arrayBuffer->value.arrayBuffer.address; |
| 159 | if (bufferInfo->value.bufferInfo.maxLength < 0) |
| 160 | fxReport(the, "# Use xsArrayBufferResizable instead of xsArrayBuffer\n"); |
| 161 | if (length != target) { |
| 162 | if (address) |
| 163 | address = (txByte*)fxRenewChunk(the, address, target); |
| 164 | if (address) { |
| 165 | if (length < target) |
| 166 | c_memset(address + length, 0, target - length); |
| 167 | } |
| 168 | else { |
| 169 | address = (txByte*)fxNewChunk(the, target); |
| 170 | if (length < target) { |
| 171 | c_memcpy(address, arrayBuffer->value.arrayBuffer.address, length); |
| 172 | c_memset(address + length, 0, target - length); |
| 173 | } |
| 174 | else |
| 175 | c_memcpy(address, arrayBuffer->value.arrayBuffer.address, target); |
| 176 | } |
| 177 | arrayBuffer->value.arrayBuffer.address = address; |
| 178 | bufferInfo->value.bufferInfo.length = target; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | void* fxToArrayBuffer(txMachine* the, txSlot* slot) |
| 183 | { |
no test coverage detected