l4 handle

This commit is contained in:
Youmu Liu
2026-03-09 18:14:49 +08:00
parent ae8238fca2
commit d97fb1dd90
12 changed files with 695 additions and 376 deletions
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="HLSFAllocator.Alloc"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -34,7 +34,9 @@ namespace StgSharp.Mathematics.Memory
public unsafe partial class HybridLayerSegregatedFitAllocator
{
public hlsfHandle Alloc(long size)
public partial hlsfHandle Alloc(
long size
)
{
if (size > _maxSize) {
throw new InvalidOperationException("Requested size exceeds maximum allocatable size.");
@@ -91,7 +93,10 @@ namespace StgSharp.Mathematics.Memory
/// <param name="sizeToSlice">
///
/// </param>
private void SliceMemory(Entry* e, long sizeToSlice)
private void SliceMemory(
Entry* e,
long sizeToSlice
)
{
Entry* next = e;
long remain = sizeToSlice; // remained size to slice
@@ -189,7 +194,9 @@ namespace StgSharp.Mathematics.Memory
/// <returns>
/// True if allocation succeeded
/// </returns>
private bool TryAllocateNew32MBBlock(out Entry* handle)
private bool TryAllocateNew32MBBlock(
out Entry* handle
)
{
nuint pos = _spareMemory->Position;
long remain = _spareMemory->Size;
@@ -219,7 +226,11 @@ namespace StgSharp.Mathematics.Memory
/// <summary>
/// Helper method for allocation - converts BucketNode to Entry
/// </summary>
private bool TryPopLevelForAllocation(int levelIndex, int sizeIndex, out Entry* entry)
private bool TryPopLevelForAllocation(
int levelIndex,
int sizeIndex,
out Entry* entry
)
{
if (TryPopLevel(levelIndex, sizeIndex, out BucketNode* bucketNode))
{