You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/wasmsamples/RunWasm.c
+10-6Lines changed: 10 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ int CalcFib(int n)
36
36
}
37
37
}
38
38
39
-
// This function receives an array of bytes followed by a length and then returns a pointer to a buffer where the first 4 bytes is the length followed by the data.
39
+
// This function receives an array of bytes followed by a length and then returns a buffer where the first 4 bytes is the length followed by the data.
40
40
__attribute__((export_name("ReceiveByteArray")))
41
41
void*ReceiveByteArray(void*data, intlength) {
42
42
@@ -45,15 +45,17 @@ void* ReceiveByteArray(void* data, int length) {
45
45
result+=4;
46
46
memcpy(result, data, length);
47
47
result-=4;
48
-
returnresult;
48
+
free(data); // Free the guest parameter, which we own
49
+
returnresult; // Transfer ownership of return value to host
0 commit comments