Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3a3e908

Browse filesBrowse files
committed
Avoid lengthBytesUTF8
1 parent 2aff403 commit 3a3e908
Copy full SHA for 3a3e908

File tree

1 file changed

+4
-8
lines changed
Filter options

1 file changed

+4
-8
lines changed

‎src/api.js

Copy file name to clipboardExpand all lines: src/api.js
+4-8Lines changed: 4 additions & 8 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.