Skip to content

Commit

Permalink
fix build and deprecated StackAllocator
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Piolat committed Oct 26, 2023
1 parent 3192a23 commit 801897f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 37 deletions.
37 changes: 2 additions & 35 deletions core/dplug/core/stackallocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ Stack allocator for temporary allocations.
Copyright: Auburn Sounds 2019.
License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
*/
// TODO deprecated("Will be removed in Dplug v15") for the module itself
module dplug.core.stackallocator;

import core.stdc.stdlib: malloc, free;
import dplug.core.vec;

struct StackAllocator
deprecated("Will be removed in Dplug v14") struct StackAllocator
{
private:
Vec!(ubyte*) bucketArray;
Expand Down Expand Up @@ -76,37 +77,3 @@ public:
currentPageFreeBytes = PAGE_SIZE;
}
}

unittest
{
StackAllocator allocator;
auto saved = allocator.saveState;
uint[] arr = allocator.makeArray!uint(10);
arr[] = 42;
assert(arr.length == 10);
allocator.restoreState(saved);

uint[] arr2 = allocator.makeArray!uint(10);
arr2[] = 48;

assert(arr[0] == 48);

// multiple allocations
uint[] arr3 = allocator.makeArray!uint(10);
arr3[] = 60;

// doesn't overwrite arr2
assert(arr2[0] == 48);
assert(arr2[$-1] == 48);

allocator.restoreState(saved);

// test new page allocation
allocator.makeArray!uint(1);
allocator.makeArray!uint(StackAllocator.PAGE_SIZE / uint.sizeof);

allocator.restoreState(saved);

// test page reuse
allocator.makeArray!uint(StackAllocator.PAGE_SIZE / uint.sizeof);
}
4 changes: 2 additions & 2 deletions graphics/dplug/graphics/draw.d
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ void fillSector(V, COLOR)(auto ref V v, int x, int y, int r0, int r1, real a0, r
{
int x0 = x>r1?x-r1:0;
int y0 = y>r1?y-r1:0;
int x1 = x+r;
int x1 = x+r1;
if (x1 > v.w-1)
x1 = v.w-1;
int y1 = y+r;
int y1 = y+r1;
if (y1 > v.h-1)
y1 = v.h-1;

Expand Down

0 comments on commit 801897f

Please sign in to comment.