MCPcopy Create free account
hub / github.com/GoogleChrome/samples / __allocCString

Function __allocCString

sqlite-wasm-cos/sqlite3.mjs:10355–10366  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

10353 to the configured dealloc() function.
10354 */
10355 const __allocCString = function(str){
10356 const u = __utf8Encoder.encode(str);
10357 const mem = alloc(u.length+1);
10358 if(!mem) toss("Allocation error while duplicating string:",str);
10359 const h = heap();
10360 //let i = 0;
10361 //for( ; i < u.length; ++i ) h[mem + i] = u[i];
10362 h.set(u, Number(mem));
10363 h[__ptrAdd(mem, u.length)] = 0;
10364 //log("allocCString @",mem," =",u);
10365 return mem;
10366 };
10367
10368 /**
10369 Sets the given struct member of obj to a dynamically-allocated,

Callers 1

__setMemberCStringFunction · 0.70

Calls 4

encodeMethod · 0.80
setMethod · 0.80
tossFunction · 0.70
__ptrAddFunction · 0.70

Tested by

no test coverage detected