-
I have been tinkering with this project, trying to figure out how it works, by exposing the C14N functionality of libxml2. I have added this function:
And this simple test:
However, the error The result of Here is the commit: shunkica/libxml2-wasm/commit/5a60a39 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Yes I can reproduce this. It seems that this memory in C doesn't map to the js buffer HEAPU8/HEAP32 for some reason. |
Beta Was this translation helpful? Give feedback.
-
The problem is in the following snippet: import {
xmlC14NDocDumpMemory,
} from './libxml2.mjs';
import type { XmlDocument } from './document.mjs';
import moduleLoader from './libxml2raw.mjs';
const libxml2 = await moduleLoader();
export function canonicalize(document: XmlDocument): string {
const docTxtPtr = libxml2._malloc(4);
const result = xmlC14NDocDumpMemory(document._ptr, 0, 0, 0, 0, docTxtPtr);
So in this code snippet, However, you are allocating space in the local instance to receive the pointer. That's why it failed. |
Beta Was this translation helpful? Give feedback.
The problem is in the following snippet:
moduleLoader
is a function that creates a WASM module.libxml2.mts
callsmoduleLoader
to create one, and exports its functions. Let's call this instance of libxml2 global.In your code, you created a new instance, by calling
moduleLoader
, and let's call this instance local.So i…