Skip to content

Commit

Permalink
Documented buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
mullerj committed Jul 22, 2024
1 parent 2a41c44 commit d4113ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/dotnet/src/Mil.Navy.Nrl.Norm/Buffers/ByteBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

namespace Mil.Navy.Nrl.Norm.Buffers
{
/// <summary>
/// A byte buffer
/// </summary>
public abstract class ByteBuffer : SafeBuffer
{
/// <summary>
/// Creates a new buffer
/// </summary>
protected ByteBuffer() : base(true)
{
}

/// <summary>
/// Allocates a new direct byte buffer
/// </summary>
/// <param name="capacity">The new buffer's capacity, in bytes</param>
/// <returns>The new byte buffer</returns>
public static ByteBuffer AllocateDirect(int capacity) {
return new DirectByteBuffer(capacity);
}
Expand Down
11 changes: 11 additions & 0 deletions src/dotnet/src/Mil.Navy.Nrl.Norm/Buffers/DirectByteBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@

namespace Mil.Navy.Nrl.Norm.Buffers
{
/// <summary>
/// A direct byte buffer
/// </summary>
internal sealed class DirectByteBuffer : ByteBuffer
{
/// <summary>
/// Creates a new direct byte buffer with given capacity
/// </summary>
/// <param name="capacity">The new buffer's capacity, in bytes</param>
internal DirectByteBuffer(int capacity)
{
SetHandle(Marshal.AllocHGlobal(capacity));
Initialize(Convert.ToUInt64(capacity));
}

/// <summary>
/// Executes the code required to free the handle
/// </summary>
/// <returns>true if the handle is released successfully; otherwise, in the event of a catastrophic failure, false</returns>
protected override bool ReleaseHandle()
{
Marshal.FreeHGlobal(handle);
Expand Down

0 comments on commit d4113ce

Please sign in to comment.