Skip to content

Snappy ffi example uses u8 instead of c_char #345

Closed
@aboseley

Description

@aboseley

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions