Skip to content

Commit 3a3e908

Browse files
committed
Avoid lengthBytesUTF8
1 parent 2aff403 commit 3a3e908

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/api.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
_malloc
66
_free
77
getValue
8-
intArrayFromString
98
setValue
109
stackAlloc
1110
stackRestore
1211
stackSave
1312
UTF8ToString
14-
stringToUTF8
15-
lengthBytesUTF8
13+
stringToNewUTF8
1614
allocateUTF8OnStack
1715
removeFunction
1816
addFunction
17+
writeArrayToMemory
1918
*/
2019

2120
"use strict";
@@ -543,14 +542,13 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
543542
pos = this.pos;
544543
this.pos += 1;
545544
}
546-
var length = lengthBytesUTF8(string);
547545
var strptr = stringToNewUTF8(string);
548546
this.allocatedmem.push(strptr);
549547
this.db.handleError(sqlite3_bind_text(
550548
this.stmt,
551549
pos,
552550
strptr,
553-
length - 1,
551+
-1,
554552
0
555553
));
556554
return true;
@@ -733,12 +731,10 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
733731
*/
734732
function StatementIterator(sql, db) {
735733
this.db = db;
736-
var sz = lengthBytesUTF8(sql) + 1;
737-
this.sqlPtr = _malloc(sz);
734+
this.sqlPtr = stringToNewUTF8(sql);
738735
if (this.sqlPtr === null) {
739736
throw new Error("Unable to allocate memory for the SQL string");
740737
}
741-
stringToUTF8(sql, this.sqlPtr, sz);
742738
this.nextSqlPtr = this.sqlPtr;
743739
this.nextSqlString = null;
744740
this.activeStatement = null;

0 commit comments

Comments
 (0)