Clarify Ownership and Lifetime of String Returned by ogex_version #9

Closed
opened 2026-03-11 18:06:30 +03:00 by NiXTheDev · 0 comments
NiXTheDev commented 2026-03-11 18:06:30 +03:00 (Migrated from github.com)

Goal: Ensure users of the C API understand they should not free the string returned by ogex_version.

Currently, ogex_version returns a *const c_char pointing to a static byte string. The function signature does not indicate whether the caller is responsible for freeing the memory.

Documentation Improvement:
Add a comment above the function in ffi.rs and in the public header (if any) stating:

/**
 * Returns a pointer to a static, null-terminated string containing the library version.
 * The string does not need to be freed by the caller.
 */

Also ensure that the returned pointer is valid for the lifetime of the program.

Implementation:

  • The current implementation uses a static byte slice with a null terminator, which is fine.
  • No code change needed, just documentation.
**Goal**: Ensure users of the C API understand they should not free the string returned by `ogex_version`. Currently, `ogex_version` returns a `*const c_char` pointing to a static byte string. The function signature does not indicate whether the caller is responsible for freeing the memory. **Documentation Improvement**: Add a comment above the function in `ffi.rs` and in the public header (if any) stating: ```c /** * Returns a pointer to a static, null-terminated string containing the library version. * The string does not need to be freed by the caller. */ ``` Also ensure that the returned pointer is valid for the lifetime of the program. **Implementation**: - The current implementation uses a static byte slice with a null terminator, which is fine. - No code change needed, just documentation.
Sign in to join this conversation.
No description provided.