Treat pointers up to 4096 as null, matching our test values in ldk-c-bindings
authorMatt Corallo <git-ldk-build@bluematt.me>
Tue, 2 Nov 2021 20:41:50 +0000 (20:41 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 4 Nov 2021 05:03:28 +0000 (05:03 +0000)
java_strings.py
typescript_strings.py

index 1d28d0d1007e0a12acbc9cf9e792a9603ef910dc..5654a3dd5295d64d81484664f33116696f41fb9b 100644 (file)
@@ -115,7 +115,7 @@ import java.util.LinkedList;
 class CommonBase {
        long ptr;
        LinkedList<Object> ptrs_to = new LinkedList();
-       protected CommonBase(long ptr) { assert ptr < 0 || ptr > 1024; this.ptr = ptr; }
+       protected CommonBase(long ptr) { assert ptr < 0 || ptr > 4096; this.ptr = ptr; }
 }
 """
 
@@ -161,7 +161,7 @@ void __attribute__((constructor)) spawn_stderr_redirection() {
 
         if not DEBUG or sys.platform == "darwin":
             self.c_file_pfx = self.c_file_pfx + """#define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((uint64_t)(p) > 1024) { free(p); }
+#define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
 #define CHECK_ACCESS(p)
 """
         if not DEBUG:
@@ -298,7 +298,7 @@ static void alloc_freed(void* ptr) {
        __real_free(it);
 }
 static void FREE(void* ptr) {
-       if ((uint64_t)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
+       if ((uint64_t)ptr <= 4096) return; // Rust loves to create pointers to the NULL page for dummys
        alloc_freed(ptr);
        __real_free(ptr);
 }
@@ -1277,7 +1277,7 @@ import javax.annotation.Nullable;
                     out_java_struct += (info.arg_name)
             out_java_struct += (");\n")
             if return_type_info.java_ty == "long" and return_type_info.java_hu_ty != "long":
-                out_java_struct += "\t\tif (ret >= 0 && ret < 1024) { return null; }\n"
+                out_java_struct += "\t\tif (ret >= 0 && ret <= 4096) { return null; }\n"
 
             if return_type_info.to_hu_conv is not None:
                 if not takes_self:
index d1449c2224fda58e24d142825847c5d150059110..54159d8d85099d3c0db71e0710dd7194d5618c2f 100644 (file)
@@ -120,7 +120,7 @@ void *malloc(size_t size);
 void free(void *ptr);
 
 #define MALLOC(a, _) malloc(a)
-#define FREE(p) if ((unsigned long)(p) > 1024) { free(p); }
+#define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
 #define DO_ASSERT(a) (void)(a)
 #define CHECK(a)
 #define CHECK_ACCESS(p)
@@ -175,7 +175,7 @@ static void alloc_freed(void* ptr) {
        __real_free(it);
 }
 static void FREE(void* ptr) {
-       if ((unsigned long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
+       if ((unsigned long)ptr <= 4096) return; // Rust loves to create pointers to the NULL page for dummys
        alloc_freed(ptr);
        __real_free(ptr);
 }