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

Function __allocCString

sqlite-wasm-cos/sqlite3-node.mjs:10234–10245  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

10232 to the configured dealloc() function.
10233 */
10234 const __allocCString = function(str){
10235 const u = __utf8Encoder.encode(str);
10236 const mem = alloc(u.length+1);
10237 if(!mem) toss("Allocation error while duplicating string:",str);
10238 const h = heap();
10239 //let i = 0;
10240 //for( ; i < u.length; ++i ) h[mem + i] = u[i];
10241 h.set(u, Number(mem));
10242 h[__ptrAdd(mem, u.length)] = 0;
10243 //log("allocCString @",mem," =",u);
10244 return mem;
10245 };
10246
10247 /**
10248 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