Skip to content

Conversation

@TIHan
Copy link
Contributor

@TIHan TIHan commented Jul 7, 2021

@vzarytovskii correctly pointed out that we can't set the length of a memory mapped file. It's already fixed length so it should be safe to not do it.

stream.SetLength(stream.Length + length)
let span = Span<byte>(stream.PositionPointer |> NativePtr.toVoidPtr, int length)
bytes.Span.CopyTo(span)
stream.Position <- stream.Position + length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to set the position here too?

Copy link
Contributor Author

@TIHan TIHan Jul 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea as TryFromByteMemory version does not reset the stream's position once it's copied.

@TIHan TIHan merged commit 5148e8d into dotnet:main Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants