electionguard-cpp icon indicating copy to clipboard operation
electionguard-cpp copied to clipboard

C# use IDisposable to avoid unnecessary copies

Open AddressXception opened this issue 3 years ago • 3 comments

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.

AddressXception avatar Mar 08 '21 14:03 AddressXception

intersted please assign

gagandeepp avatar Oct 06 '21 19:10 gagandeepp

@gagandeepp Have at it.

keithrfung avatar Oct 07 '21 17:10 keithrfung

@AddressXception I was able to setup dev environment of this repo. Do I need to make changes in ElectionGuard.Encryption/Group.cs? Let me know when we can connect on this ?? @keithrfung I am having some doubts related to this issue

gagandeepp avatar Oct 08 '21 08:10 gagandeepp