Skip to content

Commit 095a99a

Browse files
committed
remove usage of deprecated allocateUTF8OnStack
1 parent 2d8a410 commit 095a99a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/api.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
stackSave
1212
UTF8ToString
1313
stringToNewUTF8
14-
allocateUTF8OnStack
1514
removeFunction
1615
addFunction
1716
writeArrayToMemory
@@ -947,25 +946,27 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
947946
if (!this.db) {
948947
throw "Database closed";
949948
}
950-
var stack = stackSave();
951949
var stmt = null;
950+
var originalSqlPtr = null;
951+
var currentSqlPtr = null;
952952
try {
953-
var nextSqlPtr = allocateUTF8OnStack(sql);
953+
originalSqlPtr = stringToNewUTF8(sql);
954+
currentSqlPtr = originalSqlPtr;
954955
var pzTail = stackAlloc(4);
955956
var results = [];
956-
while (getValue(nextSqlPtr, "i8") !== NULL) {
957+
while (getValue(currentSqlPtr, "i8") !== NULL) {
957958
setValue(apiTemp, 0, "i32");
958959
setValue(pzTail, 0, "i32");
959960
this.handleError(sqlite3_prepare_v2_sqlptr(
960961
this.db,
961-
nextSqlPtr,
962+
currentSqlPtr,
962963
-1,
963964
apiTemp,
964965
pzTail
965966
));
966967
// pointer to a statement, or null
967968
var pStmt = getValue(apiTemp, "i32");
968-
nextSqlPtr = getValue(pzTail, "i32");
969+
currentSqlPtr = getValue(pzTail, "i32");
969970
// Empty statement
970971
if (pStmt !== NULL) {
971972
var curresult = null;
@@ -991,7 +992,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
991992
if (stmt) stmt["free"]();
992993
throw errCaught;
993994
} finally {
994-
stackRestore(stack);
995+
if (originalSqlPtr) _free(originalSqlPtr);
995996
}
996997
};
997998

src/exported_runtime_methods.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"UTF8ToString",
77
"stringToNewUTF8",
88
"writeArrayToMemory",
9-
"allocateUTF8OnStack",
109
"removeFunction",
1110
"addFunction"
1211
]

0 commit comments

Comments
 (0)