Skip to content

Commit

Permalink
fix(allocs.nim): blanket replace
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Dec 25, 2024
1 parent a1dc90b commit 7124ffd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions constantine/platforms/allocs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@ proc allocHeapAligned*(T: typedesc, alignment: static Natural): ptr T {.inline.}
# aligned_alloc requires allocating in multiple of the alignment.
let # Cannot be static with bitfields. Workaround https://github.com/nim-lang/Nim/issues/19040
size = sizeof(T)
requiredMem = size.roundround_step_up(alignment)
requiredMem = size.round_step_up(alignment)

cast[ptr T](aligned_alloc(alignment, requiredMem))

proc allocHeapUncheckedAligned*(T: typedesc, size: int, alignment: static Natural): ptr T {.inline.} =
## Aligned heap allocation for types containing a variable-sized UncheckedArray field
## or an importc type with missing size information
# aligned_alloc requires allocating in multiple of the alignment.
let requiredMem = size.roundround_step_up(alignment)
let requiredMem = size.round_step_up(alignment)

cast[ptr T](aligned_alloc(alignment, requiredMem))

proc allocHeapArrayAligned*(T: typedesc, len: int, alignment: static Natural): ptr UncheckedArray[T] {.inline.} =
# aligned_alloc requires allocating in multiple of the alignment.
let
size = sizeof(T) * len
requiredMem = size.roundround_step_up(alignment)
requiredMem = size.round_step_up(alignment)

cast[ptr UncheckedArray[T]](aligned_alloc(alignment, requiredMem))

Expand Down

0 comments on commit 7124ffd

Please sign in to comment.