Add allocator functions to c-api#8168
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe crate adds a new public ChangesC API pymem exports
Sequence Diagram(s)sequenceDiagram
participant CCaller
participant PymemRs
participant Libc
CCaller->>PymemRs: call PyMem_* or PyMem_Raw*
PymemRs->>Libc: malloc/calloc/realloc/free
Libc-->>PymemRs: allocation result or completion
PymemRs-->>CCaller: return pointer or void
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
bc43086 to
ea59686
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/capi/src/pymem.rs`:
- Around line 4-15: Normalize zero-size inputs in the CPython memory wrappers so
they satisfy the C-API contract: update PyMem_Malloc, PyMem_Calloc, and
PyMem_Realloc to treat zero-byte requests as 1-byte allocations and ensure
realloc with a zero new_size does not free the block. Apply the same zero-size
normalization consistently to PyMem_RawMalloc, PyMem_RawCalloc, and
PyMem_RawRealloc so all memory entry points in pymem.rs behave the same way
instead of forwarding raw zero values directly to libc.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: a41f31dc-588b-4ce4-9d78-2a6eb0c7ed5b
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
crates/capi/Cargo.tomlcrates/capi/src/lib.rscrates/capi/src/pymem.rs
ea59686 to
5e7a490
Compare
Summary by CodeRabbit
New Features
Chores