Skip to content

Commit 9d6ad49

Browse files
committedMar 17, 2025
Remove usage of emscripten's allocate function.
This function is deprecated upstream.
1 parent b78df58 commit 9d6ad49

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed
 

‎src/api.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
UTF8ToString
1414
stringToUTF8
1515
lengthBytesUTF8
16-
allocate
17-
ALLOC_NORMAL
1816
allocateUTF8OnStack
1917
removeFunction
2018
addFunction
@@ -545,8 +543,8 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
545543
pos = this.pos;
546544
this.pos += 1;
547545
}
548-
var bytes = intArrayFromString(string);
549-
var strptr = allocate(bytes, ALLOC_NORMAL);
546+
var length = lengthBytesUTF8(string);
547+
var strptr = stringToNewUTF8(string);
550548
this.allocatedmem.push(strptr);
551549
this.db.handleError(sqlite3_bind_text(
552550
this.stmt,
@@ -563,7 +561,8 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
563561
pos = this.pos;
564562
this.pos += 1;
565563
}
566-
var blobptr = allocate(array, ALLOC_NORMAL);
564+
var blobptr = _malloc(array.length);
565+
writeArrayToMemory(array, blobptr)
567566
this.allocatedmem.push(blobptr);
568567
this.db.handleError(sqlite3_bind_blob(
569568
this.stmt,
@@ -1204,7 +1203,8 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
12041203
if (result === null) {
12051204
sqlite3_result_null(cx);
12061205
} else if (result.length != null) {
1207-
var blobptr = allocate(result, ALLOC_NORMAL);
1206+
var blobptr = _malloc(result.length);
1207+
writeArrayToMemory(array, blobptr)
12081208
sqlite3_result_blob(cx, blobptr, result.length, -1);
12091209
_free(blobptr);
12101210
} else {

‎src/exported_runtime_methods.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
"stackSave",
55
"stackRestore",
66
"UTF8ToString",
7-
8-
"allocate",
9-
"ALLOC_NORMAL",
7+
"writeArrayToMemory",
108
"allocateUTF8OnStack",
119
"removeFunction",
1210
"addFunction"

0 commit comments

Comments
 (0)
Failed to load comments.