add malloc stubs
[m6w6/ext-psi] / psi.d / stdlib.psi
index 0b4a5067b30608adcd877a2435dbcfb53a37113b..8191c2f2bbbdfc4ec6fc08f3894e8a602a3c531e 100644 (file)
@@ -35,3 +35,23 @@ function psi\free(object $memory) : void {
        let ptr = objval($memory);
        return void(free);
 }
+
+function psi\malloc(int $size) : object {
+       let size = intval($size);
+       pre_assert size >= 0;
+       return to_object(malloc);
+}
+
+function psi\calloc(int $nmemb, int $size) : object {
+       let nmemb = intval($nmemb);
+       let size = intval($size);
+       pre_assert size >= 0;
+       return to_object(calloc);
+}
+
+function psi\realloc(object $obj, int $size) : object {
+       let ptr = objval($obj);
+       let size = intval($size);
+       pre_assert size >= 0;
+       return to_object(realloc);
+}