aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-03-11 00:57:31 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-03-11 00:57:31 -0500
commitee7a6272742ce9b50e5b3f0dfc2f2623f36e9057 (patch)
treeb5481f6b55064325d5f504f568e615fda574b9a5 /lib
parent606e9b3331e73d68da38ec8139051ee1d0149061 (diff)
Data buffer patch
Diffstat (limited to 'lib')
-rw-r--r--lib/Net.Http/src/Helpers/InitDataBuffer.cs4
-rw-r--r--lib/Utils/src/Memory/Diagnostics/HeapStatistics.cs26
2 files changed, 4 insertions, 26 deletions
diff --git a/lib/Net.Http/src/Helpers/InitDataBuffer.cs b/lib/Net.Http/src/Helpers/InitDataBuffer.cs
index 36e1f11..8dab633 100644
--- a/lib/Net.Http/src/Helpers/InitDataBuffer.cs
+++ b/lib/Net.Http/src/Helpers/InitDataBuffer.cs
@@ -60,7 +60,7 @@ namespace VNLib.Net.Http.Core
/// <returns>The newly allocated data buffer</returns>
internal static InitDataBuffer AllocBuffer(ArrayPool<byte> pool, int dataSize)
{
- //Alloc buffer
+ //Alloc buffer, must be zeroed
byte[] buffer = pool.Rent(dataSize + POSITION_SEG_SIZE, true);
return new(pool, buffer, dataSize);
@@ -111,7 +111,7 @@ namespace VNLib.Net.Http.Core
//Calc how many bytes can be read into the output buffer
int bytesToRead = Math.Min(Remaining, buffer.Length);
- Span<byte> btr = DataSegment[Position..bytesToRead];
+ Span<byte> btr = DataSegment.Slice(Position, bytesToRead);
//Write data to output buffer
btr.CopyTo(buffer);
diff --git a/lib/Utils/src/Memory/Diagnostics/HeapStatistics.cs b/lib/Utils/src/Memory/Diagnostics/HeapStatistics.cs
index ec9fe0c..5d7d3f1 100644
--- a/lib/Utils/src/Memory/Diagnostics/HeapStatistics.cs
+++ b/lib/Utils/src/Memory/Diagnostics/HeapStatistics.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2022 Vaughn Nugent
+* Copyright (c) 2023 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Utils
@@ -22,15 +22,13 @@
* along with VNLib.Utils. If not, see http://www.gnu.org/licenses/.
*/
-using System;
-
namespace VNLib.Utils.Memory.Diagnostics
{
/// <summary>
/// A structures that represents the current/last captures
/// statistics of the monitored heap
/// </summary>
- public readonly struct HeapStatistics : IEquatable<HeapStatistics>
+ public readonly record struct HeapStatistics
{
/// <summary>
/// The current size (in bytes) of the heap
@@ -52,25 +50,5 @@ namespace VNLib.Utils.Memory.Diagnostics
/// The number of allocated handles/blocks
/// </summary>
public readonly ulong AllocatedBlocks { get; init; }
-
- ///<inheritdoc/>
- public override bool Equals(object? obj) => obj is HeapStatistics s && Equals(s);
-
- ///<inheritdoc/>
- public override int GetHashCode() => (int)((AllocatedBytes ^ MaxBlockSize) & int.MaxValue);
-
- ///<inheritdoc/>
- public static bool operator ==(HeapStatistics left, HeapStatistics right) => left.Equals(right);
- ///<inheritdoc/>
- public static bool operator !=(HeapStatistics left, HeapStatistics right) => !(left == right);
-
- ///<inheritdoc/>
- public bool Equals(HeapStatistics other)
- {
- return MinBlockSize == other.MinBlockSize
- && MaxBlockSize == other.MaxBlockSize
- && MaxHeapSize == other.MaxHeapSize
- && AllocatedBytes == other.AllocatedBytes;
- }
}
}