mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Minor internal JS code/docs cleanups.
FossilOrigin-Name: 21331bdd36a91b07a687ffadce392dcf2ccd0fd824b35d9dd027d4289a40fc96
This commit is contained in:
@ -943,10 +943,19 @@ self.WhWasmUtilInstaller = function(target){
|
||||
const __allocCStr = function(jstr, returnWithLength, allocator, funcName){
|
||||
__affirmAlloc(target, funcName);
|
||||
if('string'!==typeof jstr) return null;
|
||||
const n = target.jstrlen(jstr),
|
||||
ptr = allocator(n+1);
|
||||
target.jstrcpy(jstr, target.heap8u(), ptr, n+1, true);
|
||||
return returnWithLength ? [ptr, n] : ptr;
|
||||
if(0){/* older impl, possibly more widely compatible? */
|
||||
const n = target.jstrlen(jstr),
|
||||
ptr = allocator(n+1);
|
||||
target.jstrcpy(jstr, target.heap8u(), ptr, n+1, true);
|
||||
return returnWithLength ? [ptr, n] : ptr;
|
||||
}else{/* newer, (probably) faster and (certainly) simpler impl */
|
||||
const u = cache.utf8Encoder.encode(jstr),
|
||||
ptr = allocator(u.length+1),
|
||||
heap = heapWrappers().HEAP8U;
|
||||
heap.set(u, ptr);
|
||||
heap[ptr + u.length] = 0;
|
||||
return returnWithLength ? [ptr, u.length] : ptr;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user