tursodatabase / tursodatabase/libsql
Return string length alongside pointer in C bindings
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
Currently the C bindings function has the following signature:
pub unsafe extern "C" fn libsql_get_string(
res: libsql_row_t,
col: std::ffi::c_int,
out_value: *mut *const std::ffi::c_char,
out_err_msg: *mut *const std::ffi::c_char,
) -> std::ffi::c_int
I think it would be a good idea to include the length of the string which I understand is already available to the Rust runtime instead of making the foreign runtime traverse the pointer to find the null character to copy it into its own memory.
pub unsafe extern "C" fn libsql_get_string(
res: libsql_row_t,
col: std::ffi::c_int,
out_value: *mut *const std::ffi::c_char,
+ out_len: *mut *const c_int,
out_err_msg: *mut *const std::ffi::c_char,
) -> std::ffi::c_int
or whatever type is appropriate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation and foreign callers of the libsql_get_string C binding; the issue does not name a file or test. Determine the appropriate length type and how the existing string length is exposed, then update the binding and verify that callers can receive the length without scanning for a null character.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- api, databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100