Skip to content

Commit 443769e

Browse files
fix: Don't allocate extraneous memory in FastBufferReader (#2265)
* fix: Don't allocate extraneous memory in FastBufferReader * Add PR number to CHANGELOG entry
1 parent 30d23bc commit 443769e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
77

88
Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).
99

10+
## [Unreleased]
11+
12+
### Fixed
13+
14+
- Creating a `FastBufferReader` with `Allocator.None` will not result in extra memory being allocated for the buffer (since it's owned externally in that scenario). (#2265)
15+
1016
## [1.1.0] - 2022-10-21
1117

1218
### Added

com.unity.netcode.gameobjects/Runtime/Serialization/FastBufferReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal unsafe void CommitBitwiseReads(int amount)
6565
ReaderHandle* readerHandle = null;
6666
if (copyAllocator == Allocator.None)
6767
{
68-
readerHandle = (ReaderHandle*)UnsafeUtility.Malloc(sizeof(ReaderHandle) + length, UnsafeUtility.AlignOf<byte>(), internalAllocator);
68+
readerHandle = (ReaderHandle*)UnsafeUtility.Malloc(sizeof(ReaderHandle), UnsafeUtility.AlignOf<byte>(), internalAllocator);
6969
readerHandle->BufferPointer = buffer;
7070
readerHandle->Position = offset;
7171
}

0 commit comments

Comments
 (0)