diff options
author | 2022-04-29 06:08:36 -0700 | |
---|---|---|
committer | 2022-04-29 06:08:36 -0700 | |
commit | 22f74756b4cf173749b2f72fdae438f8def24bd2 (patch) | |
tree | 7af47e7ee0ba1ab1bfc8a2ffd3672f9b5e6b58af /integration/bunjs-only-snippets/ffi-test.c | |
parent | f07463bdfdcdd312e0d2aaf2f73bb71646f5f8a3 (diff) | |
download | bun-22f74756b4cf173749b2f72fdae438f8def24bd2.tar.gz bun-22f74756b4cf173749b2f72fdae438f8def24bd2.tar.zst bun-22f74756b4cf173749b2f72fdae438f8def24bd2.zip |
[bun ffi] Support pointers
Diffstat (limited to 'integration/bunjs-only-snippets/ffi-test.c')
-rw-r--r-- | integration/bunjs-only-snippets/ffi-test.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/ffi-test.c b/integration/bunjs-only-snippets/ffi-test.c index 4b2784a84..562d31784 100644 --- a/integration/bunjs-only-snippets/ffi-test.c +++ b/integration/bunjs-only-snippets/ffi-test.c @@ -1,5 +1,6 @@ #include <stdbool.h> #include <stdint.h> +#include <stdlib.h> bool returns_true(); bool returns_false(); @@ -83,3 +84,13 @@ uint8_t add_uint8_t(uint8_t a, uint8_t b) { return a + b; } uint16_t add_uint16_t(uint16_t a, uint16_t b) { return a + b; } uint32_t add_uint32_t(uint32_t a, uint32_t b) { return a + b; } uint64_t add_uint64_t(uint64_t a, uint64_t b) { return a + b; } + +void *ptr_should_point_to_42_as_int32_t(); +void *ptr_should_point_to_42_as_int32_t() { + int32_t *ptr = malloc(sizeof(int32_t)); + *ptr = 42; + return ptr; +} + +bool does_pointer_equal_42_as_int32_t(int32_t *ptr); +bool does_pointer_equal_42_as_int32_t(int32_t *ptr) { return *ptr == 42; } |