1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-21 13:38:01 +03:00

Generic internal JS cleanups towards improving portability of sqlite3-api.js to other build systems.

FossilOrigin-Name: 5bc37e5c2fcd83fd0bc40234144072363f1cbf7d811a15b74a0991e397a35eb8
This commit is contained in:
stephan
2025-11-15 11:30:45 +00:00
parent a804a65617
commit 987870a6a0
7 changed files with 96 additions and 76 deletions

View File

@@ -667,12 +667,14 @@ globalThis.WhWasmUtilInstaller = function(target){
const ft = target.functionTable();
const oldLen = __asPtrType(ft.length);
let ptr;
while(cache.freeFuncIndexes.length){
ptr = cache.freeFuncIndexes.pop();
if(ft.get(ptr)){ /* Table was modified via a different API */
while( (ptr = cache.freeFuncIndexes.pop()) ){
if(ft.get(ptr)){
/* freeFuncIndexes's entry is stale. Table was modified via a
different API */
ptr = null;
continue;
}else{
/* This index is free. We'll re-use it. */
break;
}
}
@@ -763,10 +765,9 @@ globalThis.WhWasmUtilInstaller = function(target){
has no side effects and returns undefined.
*/
target.uninstallFunction = function(ptr){
if(!ptr && 0!==ptr) return undefined;
const fi = cache.freeFuncIndexes;
if(!ptr && __NullPtr!==ptr) return undefined;
const ft = target.functionTable();
fi.push(ptr);
cache.freeFuncIndexes.push(ptr);
const rc = ft.get(ptr);
ft.set(ptr, null);
return rc;