Skip to content

[MOD-19126] c_wrapper: add owned and borrowed wrappers for C fat arrays - #11641

Merged
gdesmott merged 1 commit into
masterfrom
gdesmott-c-array-wrapper
Oct 5, 2026
Merged

gdesmott merged 1 commit into
masterfrom
gdesmott-c-array-wrapper

Conversation

@gdesmott

@gdesmott gdesmott commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

  1. Current: Rust code that receives a C fat array (arrayof(T)) has to call array_len_func/array_free by hand in its own unsafe blocks, with nothing tying the array's lifetime or ownership to the Rust side.
  2. Change: A new fat_array crate under c_wrappers/ adds FatArray<T: Copy>, which owns a fat array and frees it on drop, and FatArrayRef<'a, T>, which borrows one (null counts as empty). Both expose the elements as a slice.
  3. Outcome: Internal-only, no user-visible change. It gives upcoming ports a single audited place to read and free C fat arrays.

Which additional issues this PR fixes

N/A

Main objects this PR modified

  1. fat_array::FatArray / FatArrayRef — new safe wrappers over C fat arrays. Their safety contracts require the array's element size and alignment to match T; debug builds assert both.
  2. ffi — binds array_hdr_t so that element-size check can read the header.

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

If a release note is required (bug fix / new feature / enhancement), describe the user impact of this PR in the title.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 76b5d7fb8d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gdesmott
gdesmott force-pushed the gdesmott-c-array-wrapper branch 7 times, most recently from d3fff67 to 6e05ec4 Compare September 30, 2026 11:03
@gdesmott gdesmott changed the title c_wrapper: add owned and borrowed wrappers for C fat arrays [MOD-19126] c_wrapper: add owned and borrowed wrappers for C fat arrays Sep 30, 2026
@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.87755% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.53%. Comparing base (af82b35) to head (b33e522).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/redisearch_rs/c_wrappers/fat_array/src/lib.rs 93.87% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11641      +/-   ##
==========================================
- Coverage   84.13%   83.53%   -0.61%     
==========================================
  Files         643      669      +26     
  Lines       85119    86387    +1268     
  Branches    39311    40561    +1250     
==========================================
+ Hits        71617    72160     +543     
- Misses      13139    13856     +717     
- Partials      363      371       +8     
Flag Coverage Δ
flow 84.58% <ø> (-0.03%) ⬇️
unit 58.88% <93.87%> (-0.24%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gdesmott
gdesmott force-pushed the gdesmott-c-array-wrapper branch from 6e05ec4 to 6b02724 Compare October 5, 2026 12:21

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b02724189

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gdesmott
gdesmott force-pushed the gdesmott-c-array-wrapper branch from 6b02724 to 39b925e Compare October 5, 2026 12:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39b925e52a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Add the fat_array crate with FatArray, which owns a C fat array, and
FatArrayRef, which borrows one for a lifetime, both exposing the
elements as a slice.

Dropping a FatArray drops each element, then frees the storage with
array_free, even if an element's destructor panics. Debug builds check
that the array's element size and alignment match T, which requires
binding array_hdr_t.
@gdesmott
gdesmott force-pushed the gdesmott-c-array-wrapper branch from 39b925e to b33e522 Compare October 5, 2026 12:56
@gdesmott
gdesmott added this pull request to the merge queue Oct 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

Merged via the queue into master with commit 425635b Oct 5, 2026
61 checks passed
@gdesmott
gdesmott deleted the gdesmott-c-array-wrapper branch October 5, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants