fix: consolidate duplicate FFISyncProgress destroy functions#474
fix: consolidate duplicate FFISyncProgress destroy functions#474xdustinface merged 1 commit intov0.42-devfrom
FFISyncProgress destroy functions#474Conversation
📝 WalkthroughWalkthroughPublic FFI destructor for FFISyncProgress was renamed from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
dash-spv-ffi/src/client.rs (1)
408-423:⚠️ Potential issue | 🟡 Minor
dash_spv_ffi_client_get_sync_progressis missing a destroy hint in its doc comment.
dash_spv_ffi_client_get_manager_sync_progress(Line 428) was updated in this PR to referencedash_spv_ffi_sync_progress_destroy, but the sibling functiondash_spv_ffi_client_get_sync_progressreturns the same*mut FFISyncProgresstype without mentioning how to free it.📝 Suggested doc update
/// Get the current sync progress snapshot. /// +/// Use `dash_spv_ffi_sync_progress_destroy` to free the returned struct. +/// /// # Safety /// - `client` must be a valid, non-null pointer.The same one-liner should also be added to the corresponding declaration in
dash-spv-ffi/include/dash_spv_ffi.h(around line 511–514).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dash-spv-ffi/src/client.rs` around lines 408 - 423, Add the missing "destroy" hint to the doc comment for dash_spv_ffi_client_get_sync_progress stating that the returned *mut FFISyncProgress must be freed with dash_spv_ffi_sync_progress_destroy (mirror the comment added to dash_spv_ffi_client_get_manager_sync_progress); also update the corresponding declaration comment in the C header (dash_spv_ffi.h) for the client function to reference dash_spv_ffi_sync_progress_destroy so both Rust export and C header consistently document how to free the FFISyncProgress pointer.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@dash-spv-ffi/src/client.rs`:
- Around line 408-423: Add the missing "destroy" hint to the doc comment for
dash_spv_ffi_client_get_sync_progress stating that the returned *mut
FFISyncProgress must be freed with dash_spv_ffi_sync_progress_destroy (mirror
the comment added to dash_spv_ffi_client_get_manager_sync_progress); also update
the corresponding declaration comment in the C header (dash_spv_ffi.h) for the
client function to reference dash_spv_ffi_sync_progress_destroy so both Rust
export and C header consistently document how to free the FFISyncProgress
pointer.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
dash-spv-ffi/FFI_API.mddash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/src/types.rsdash-spv-ffi/tests/test_types.rs
`dash_spv_ffi_sync_progress_destroy` didn't cleanup the nested progress pointers which leads to leaks on cleanup. This PR merges `dash_spv_ffi_sync_progress_destroy` into `dash_spv_ffi_manager_sync_progress_destroy`.
979e43b to
24ee468
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
dash-spv-ffi/FFI_API.md (1)
476-489:⚠️ Potential issue | 🟡 Minor
dash_spv_ffi_client_get_sync_progressdetailed section is missing the free-function reference.The
dash_spv_ffi_client_get_manager_sync_progressentry (line 467) was updated to mentiondash_spv_ffi_sync_progress_destroy, but thedash_spv_ffi_client_get_sync_progressentry (lines 476-489) has no equivalent note. Both functions return an owned*mut FFISyncProgressthat requires the same cleanup call.📝 Suggested doc update
**Description:** -Get the current sync progress snapshot. # Safety - `client` must be a valid, non-null pointer. +Get the current sync progress snapshot. Use `dash_spv_ffi_sync_progress_destroy` to free the returned struct. # Safety - `client` must be a valid, non-null pointer.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dash-spv-ffi/FFI_API.md` around lines 476 - 489, Update the documentation for dash_spv_ffi_client_get_sync_progress to match the manager variant: state that the returned pointer is owned and must be freed with dash_spv_ffi_sync_progress_destroy; specifically, add a Safety/Notes sentence near the function signature (as done for dash_spv_ffi_client_get_manager_sync_progress) indicating callers must call dash_spv_ffi_sync_progress_destroy on the returned *mut FFISyncProgress to avoid leaks and ensure consistent docs for the functions dash_spv_ffi_client_get_sync_progress and dash_spv_ffi_client_get_manager_sync_progress.dash-spv-ffi/src/client.rs (1)
408-423:⚠️ Potential issue | 🟡 Minor
dash_spv_ffi_client_get_sync_progressis missing the free-function doc.
get_manager_sync_progress(line 428) was updated to documentdash_spv_ffi_sync_progress_destroy, butget_sync_progressreturns the same heap-allocated*mut FFISyncProgresswith identical nested pointer allocation and has no such hint. Without it, callers have no indication they must call the destroy function.📝 Suggested doc update
/// Get the current sync progress snapshot. /// +/// Use `dash_spv_ffi_sync_progress_destroy` to free the returned struct. +/// /// # Safety /// - `client` must be a valid, non-null pointer.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dash-spv-ffi/src/client.rs` around lines 408 - 423, dash_spv_ffi_client_get_sync_progress returns a heap-allocated *mut FFISyncProgress but its docstring does not mention the required free function; update the doc comment on dash_spv_ffi_client_get_sync_progress (like get_manager_sync_progress) to state that the returned FFISyncProgress must be freed with dash_spv_ffi_sync_progress_destroy and mention ownership transfer semantics for FFISyncProgress::from so callers know to call the destroy function to avoid leaks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@dash-spv-ffi/FFI_API.md`:
- Around line 476-489: Update the documentation for
dash_spv_ffi_client_get_sync_progress to match the manager variant: state that
the returned pointer is owned and must be freed with
dash_spv_ffi_sync_progress_destroy; specifically, add a Safety/Notes sentence
near the function signature (as done for
dash_spv_ffi_client_get_manager_sync_progress) indicating callers must call
dash_spv_ffi_sync_progress_destroy on the returned *mut FFISyncProgress to avoid
leaks and ensure consistent docs for the functions
dash_spv_ffi_client_get_sync_progress and
dash_spv_ffi_client_get_manager_sync_progress.
In `@dash-spv-ffi/src/client.rs`:
- Around line 408-423: dash_spv_ffi_client_get_sync_progress returns a
heap-allocated *mut FFISyncProgress but its docstring does not mention the
required free function; update the doc comment on
dash_spv_ffi_client_get_sync_progress (like get_manager_sync_progress) to state
that the returned FFISyncProgress must be freed with
dash_spv_ffi_sync_progress_destroy and mention ownership transfer semantics for
FFISyncProgress::from so callers know to call the destroy function to avoid
leaks.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
dash-spv-ffi/FFI_API.mddash-spv-ffi/include/dash_spv_ffi.hdash-spv-ffi/src/callbacks.rsdash-spv-ffi/src/client.rsdash-spv-ffi/src/types.rsdash-spv-ffi/tests/test_types.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- dash-spv-ffi/include/dash_spv_ffi.h
The PR #474 somehow sneaked a failure into the CI.
The PR #474 somehow sneaked a failure into the CI.
dash_spv_ffi_sync_progress_destroydidn't cleanup the nested progress pointers which leads to leaks on cleanup. This PR mergesdash_spv_ffi_sync_progress_destroyintodash_spv_ffi_manager_sync_progress_destroy.Summary by CodeRabbit
Refactor
Documentation