Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of emscripten's allocate function. #606

Merged
merged 6 commits into from
Mar 20, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -13,8 +13,6 @@
UTF8ToString
stringToUTF8
lengthBytesUTF8
allocate
ALLOC_NORMAL
allocateUTF8OnStack
removeFunction
addFunction
@@ -545,14 +543,14 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
pos = this.pos;
this.pos += 1;
}
var bytes = intArrayFromString(string);
var strptr = allocate(bytes, ALLOC_NORMAL);
var length = lengthBytesUTF8(string);
var strptr = stringToNewUTF8(string);
this.allocatedmem.push(strptr);
this.db.handleError(sqlite3_bind_text(
this.stmt,
pos,
strptr,
bytes.length - 1,
length - 1,
0
));
return true;
@@ -563,7 +561,8 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
pos = this.pos;
this.pos += 1;
}
var blobptr = allocate(array, ALLOC_NORMAL);
var blobptr = _malloc(array.length);
writeArrayToMemory(array, blobptr)
this.allocatedmem.push(blobptr);
this.db.handleError(sqlite3_bind_blob(
this.stmt,
@@ -1204,7 +1203,8 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
if (result === null) {
sqlite3_result_null(cx);
} else if (result.length != null) {
var blobptr = allocate(result, ALLOC_NORMAL);
var blobptr = _malloc(result.length);
writeArrayToMemory(result, blobptr)
sqlite3_result_blob(cx, blobptr, result.length, -1);
_free(blobptr);
} else {
5 changes: 2 additions & 3 deletions src/exported_runtime_methods.json
Original file line number Diff line number Diff line change
@@ -4,9 +4,8 @@
"stackSave",
"stackRestore",
"UTF8ToString",

"allocate",
"ALLOC_NORMAL",
"stringToNewUTF8",
"writeArrayToMemory",
"allocateUTF8OnStack",
"removeFunction",
"addFunction"
Loading