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 1 commit
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
Prev Previous commit
Next Next commit
Avoid lengthBytesUTF8
  • Loading branch information
sbc100 committed Mar 20, 2025
commit 3a3e908fb6f0160146e77ae94c6ec2e1e8f09759
12 changes: 4 additions & 8 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -5,17 +5,16 @@
_malloc
_free
getValue
intArrayFromString
setValue
stackAlloc
stackRestore
stackSave
UTF8ToString
stringToUTF8
lengthBytesUTF8
stringToNewUTF8
allocateUTF8OnStack
removeFunction
addFunction
writeArrayToMemory
*/

"use strict";
@@ -543,14 +542,13 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
pos = this.pos;
this.pos += 1;
}
var length = lengthBytesUTF8(string);
var strptr = stringToNewUTF8(string);
this.allocatedmem.push(strptr);
this.db.handleError(sqlite3_bind_text(
this.stmt,
pos,
strptr,
length - 1,
-1,
0
));
return true;
@@ -733,12 +731,10 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
*/
function StatementIterator(sql, db) {
this.db = db;
var sz = lengthBytesUTF8(sql) + 1;
this.sqlPtr = _malloc(sz);
this.sqlPtr = stringToNewUTF8(sql);
if (this.sqlPtr === null) {
throw new Error("Unable to allocate memory for the SQL string");
}
stringToUTF8(sql, this.sqlPtr, sz);
this.nextSqlPtr = this.sqlPtr;
this.nextSqlString = null;
this.activeStatement = null;
Loading
Oops, something went wrong.