Election-Tech-Initiative / Election-Tech-Initiative/electionguard-cpp
C# use IDisposable to avoid unnecessary copies
- 主要语言
- C++
- 星标
- 26
- 派生
- 25
- PR 合并指标
- 30 天内没有已合并 PR
描述
## Feature Request
**Description**
In a few places, there are unnecessary copy operations when moving between managed and unmanaged blocks of memory. For instance:
- `Group.cs#ElementModP#NewNative`
- `Ballot.cs#CompactCiphertextBallot#ctor`
This request is to refactor the managed code to expose the unmanaged objects directly where necessary by pinning the memory and bypassing the garbage collector. IDisposable should be used on the managed side to call the unmanaged "_free" functions when necessary. Careful consideration must be given to ownership as not every contiguous block of memory returned to managed code is actually owned by the caller.
The implemented pattern should be consistently applied throughout the C# binding layer.
贡献指南
调研方向
从 Group.cs#ElementModP#NewNative 和 Ballot.cs#CompactCiphertextBallot#ctor 开始,跟踪托管内存到非托管内存的复制,以及返回内存的所有权。在定义 IDisposable 模式之前,检查周围的 C# binding 层及其非托管 _free 函数。完成的标准是安全地处理所有权,并在整个 binding 层中一致地应用该模式。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp, csharp
- 领域
- api
- Issue 类型
- 重构
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100