self.util_fn_pfx = """package org.ldk.structs;
import org.ldk.impl.bindings;
+import org.ldk.enums.*;
+import org.ldk.util.*;
import java.util.Arrays;
import javax.annotation.Nullable;
-import org.ldk.enums.*;
public class UtilMethods {
"""
self.c_file_pfx = self.c_file_pfx + """#define MALLOC(a, _) malloc(a)
#define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
#define CHECK_ACCESS(p)
+#define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
"""
if not DEBUG:
self.c_file_pfx += """#define DO_ASSERT(a) (void)(a)
__real_free(ptr);
}
-static void CHECK_ACCESS(void* ptr) {
+static void CHECK_ACCESS(const void* ptr) {
DO_ASSERT(!pthread_mutex_lock(&allocation_mtx));
allocation* it = allocation_ll;
while (it->ptr != ptr) {
}
DO_ASSERT(!pthread_mutex_unlock(&allocation_mtx));
}
+#define CHECK_INNER_FIELD_ACCESS_OR_NULL(v) \\
+ if (v.is_owned && v.inner != NULL) { \\
+ const void *p = __unmangle_inner_ptr(v.inner); \\
+ if (p != NULL) { \\
+ CHECK_ACCESS(p); \\
+ } \\
+ }
void* __real_realloc(void* ptr, size_t newlen);
void* __wrap_realloc(void* ptr, size_t len) {