MCPcopy Index your code
hub / github.com/apache/tvm / allocByteArrayForString

Method allocByteArrayForString

web/src/memory.ts:446–455  ·  view source on GitHub ↗

* Allocate a byte array for a string and return the offset of the byte array. * @param data The string to allocate. * @returns The offset of the byte array.

(data: string)

Source from the content-addressed store, hash-verified

444 * @returns The offset of the byte array.
445 */
446 allocByteArrayForString(data: string): PtrOffset {
447 const dataUint8: Uint8Array = StringToUint8Array(data);
448 // Note: size of size_t equals sizeof ptr.
449 const headerOffset = this.allocRawBytes(this.memory.sizeofPtr() * 2);
450 const dataOffset = this.allocRawBytes(dataUint8.length);
451 this.storeUSize(headerOffset + this.memory.sizeofPtr(), data.length);
452 this.storeRawBytes(dataOffset, dataUint8);
453 this.addressToSetTargetValue.push([headerOffset, dataOffset]);
454 return headerOffset;
455 }
456 /**
457 * Allocate then set C-String pointer to the offset.
458 * This function will call into allocBytes to allocate necessary data.

Callers 3

registerFuncMethod · 0.80
getGlobalFuncInternalMethod · 0.80
typeKey2IndexMethod · 0.80

Calls 5

allocRawBytesMethod · 0.95
storeUSizeMethod · 0.95
storeRawBytesMethod · 0.95
StringToUint8ArrayFunction · 0.90
sizeofPtrMethod · 0.45

Tested by

no test coverage detected