dashu icon indicating copy to clipboard operation
dashu copied to clipboard

Refactor `Memory` to reduce unsafe code

Open eduardosm opened this issue 2 years ago • 3 comments

Refactor Memory to avoid dealing with manual allocations, raw pointers and memory layouts.

Now it uses a Vec (with length zero and desired capacity) and Vec::spare_capacity_mut to access the allocated capacity.

eduardosm avatar Oct 22 '23 10:10 eduardosm

Thanks for the PR! What necessitates this change in your opinion? I think the original author of the memory allocation utilities (i.e tczajka) keeps this design because it will be easier to create customized allocation logics in future.

cmpute avatar Oct 23 '23 09:10 cmpute

Since it was only used to allocate slices of Word, I simplified it accordingly. Is there a need to allocate arbitrary layouts?

eduardosm avatar Oct 23 '23 17:10 eduardosm

This change might be related to #43 , lets wait for that issue to have a rough idea of how to improve this.

cmpute avatar Dec 19 '23 08:12 cmpute