Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snappy ffi example uses u8 instead of c_char #345

Open
aboseley opened this issue Mar 19, 2022 · 0 comments · May be fixed by #440
Open

Snappy ffi example uses u8 instead of c_char #345

aboseley opened this issue Mar 19, 2022 · 0 comments · May be fixed by #440

Comments

@aboseley
Copy link

aboseley commented Mar 19, 2022

The ffi interface in the snappy examples doesn't match the c-library types in snappy-c.h.

Should the ffi interface use libc::c_char instead of u8

https://github.com/google/snappy/blob/main/snappy-c.h#L71

   snappy_status snappy_compress(const char* input,
                              size_t input_length,
                              char* compressed,
                              size_t* compressed_length);

example here
https://doc.rust-lang.org/nomicon/ffi.html#calling-foreign-functions

   fn snappy_compress(input: *const u8,
                       input_length: size_t,
                       compressed: *mut u8,
                       compressed_length: *mut size_t) -> c_int;

Would it be clearer to have these function definition match then cast the pointer inside the rust function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant