projects
/
ldk-java
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[TS] Free native -> human arrays after we're done converting
[ldk-java]
/
typescript_strings.py
diff --git
a/typescript_strings.py
b/typescript_strings.py
index 2979481d1e9ab4648d4d532246e090284923e3ea..0d9f30b81b2293f09acb7b45f00745330e04f1a1 100644
(file)
--- a/
typescript_strings.py
+++ b/
typescript_strings.py
@@
-207,6
+207,9
@@
const decodeUint32Array = (arrayPointer: number, free = true) => {
return actualArray;
}
return actualArray;
}
+
+export function freeWasmMemory(pointer: number) { wasm.TS_free(pointer); }
+
/* @internal */
export function getU32ArrayElem(arrayPointer: number, idx: number): number {
const actualArrayViewer = new Uint32Array(wasm.memory.buffer, arrayPointer + 4, idx + 1);
/* @internal */
export function getU32ArrayElem(arrayPointer: number, idx: number): number {
const actualArrayViewer = new Uint32Array(wasm.memory.buffer, arrayPointer + 4, idx + 1);
@@
-376,8
+379,9
@@
typedef struct allocation {
static allocation* allocation_ll = NULL;
static allocation* freed_ll = NULL;
static allocation* allocation_ll = NULL;
static allocation* freed_ll = NULL;
-void* __real_malloc(size_t len);
-void* __real_calloc(size_t nmemb, size_t len);
+extern void* __real_malloc(size_t len);
+extern void* __real_calloc(size_t nmemb, size_t len);
+extern void* __real_aligned_alloc(size_t alignment, size_t size);
static void new_allocation(void* res, const char* struct_name, int lineno) {
allocation* new_alloc = __real_malloc(sizeof(allocation));
new_alloc->ptr = res;
static void new_allocation(void* res, const char* struct_name, int lineno) {
allocation* new_alloc = __real_malloc(sizeof(allocation));
new_alloc->ptr = res;
@@
-450,6
+454,11
@@
void* __wrap_calloc(size_t nmemb, size_t len) {
new_allocation(res, "calloc call", 0);
return res;
}
new_allocation(res, "calloc call", 0);
return res;
}
+void* __wrap_aligned_alloc(size_t alignment, size_t size) {
+ void* res = __real_aligned_alloc(alignment, size);
+ new_allocation(res, "aligned_alloc call", 0);
+ return res;
+}
void __wrap_free(void* ptr) {
if (ptr == NULL) return;
alloc_freed(ptr, 0);
void __wrap_free(void* ptr) {
if (ptr == NULL) return;
alloc_freed(ptr, 0);
@@
-629,6
+638,8
@@
import * as bindings from '../bindings.mjs'
assert False
def constr_hu_array(self, ty_info, arr_len):
return "new Array(" + arr_len + ").fill(null)"
assert False
def constr_hu_array(self, ty_info, arr_len):
return "new Array(" + arr_len + ").fill(null)"
+ def cleanup_converted_native_array(self, ty_info, arr_name):
+ return "bindings.freeWasmMemory(" + arr_name + ")"
def primitive_arr_from_hu(self, mapped_ty, fixed_len, arr_name):
inner = arr_name
def primitive_arr_from_hu(self, mapped_ty, fixed_len, arr_name):
inner = arr_name