You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C#] Add a typed, initialising grow/shrink API (RawMem parity); stale bytes reappear after shrink + grow #100
C# exposes only raw UsedCapacity / ReservedCapacity byte counters. Growing UsedCapacity again after shrinking it exposes stale bytes (probe P6: the byte 42 comes back). There is also no way to say "grow by N elements filled with X".
mem-rs RawMem provides len, grow_filled, grow_zeroed, grow_with, grow_from_slice, shrink, truncate, clear, resize, and Resizable::{reserve, reserve_exact, shrink_to_fit, spare_capacity}. It also has a typed slice view.
Proposed solution
Add IRawMemory<T> where T : unmanaged with:
long Length;
Span<T> AsSpan() and Span<T> Slice(long start, int length);
Shrink(long count), Truncate(long length), Clear(), Resize(long length, T fill);
Reserve(long additional) and ShrinkToFit().
Implement it once over IResizableDirectMemory (heap, file-mapped, temporary) through MemoryMarshal/Unsafe and NativeMemory.Clear. A shrink must not leave readable stale data behind for the next grow: zero the tail on grow, as mem-rs does. Keep the old properties as thin wrappers for compatibility.
Activity