Election-Tech-Initiative / Election-Tech-Initiative/electionguard-cpp

C# use IDisposable to avoid unnecessary copies

Open
#164 3 comments 0 reactions 0 assignees View on GitHub
enhancement hacktoberfest help wanted
Dominant language
C++
Stars
26
Forks
25
PR merge metrics
No merged PRs in 30d

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.