1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Export sqlite3_bind/value/result_pointer() to wasm. Add 'static-string' argument converter to support the lifetime requirements of bind/result_pointer()'s string argument. Correct an endless loop in wasm.cstrlen() when passed a non-C-string argument.

FossilOrigin-Name: a94552434a657376d5ce1831de05c1b15fb153020848cd825fb0df413c3baa70
This commit is contained in:
stephan
2022-12-05 11:30:39 +00:00
parent 08fc64ea04
commit 0adef09374
6 changed files with 55 additions and 15 deletions

View File

@ -725,11 +725,12 @@ self.WhWasmUtilInstaller = function(target){
Expects ptr to be a pointer into the WASM heap memory which
refers to a NUL-terminated C-style string encoded as UTF-8.
Returns the length, in bytes, of the string, as for `strlen(3)`.
As a special case, if !ptr then it it returns `null`. Throws if
ptr is out of range for target.heap8u().
As a special case, if !ptr or if it's not a pointer then it
returns `null`. Throws if ptr is out of range for
target.heap8u().
*/
target.cstrlen = function(ptr){
if(!ptr) return null;
if(!ptr || !target.isPtr(ptr)) return null;
const h = heapWrappers().HEAP8U;
let pos = ptr;
for( ; h[pos] !== 0; ++pos ){}
@ -753,7 +754,7 @@ self.WhWasmUtilInstaller = function(target){
refers to a NUL-terminated C-style string encoded as UTF-8. This
function counts its byte length using cstrlen() then returns a
JS-format string representing its contents. As a special case, if
ptr is falsy, `null` is returned.
ptr is falsy or not a pointer, `null` is returned.
*/
target.cstringToJs = function(ptr){
const n = target.cstrlen(ptr);