Skip to content

Commit

Permalink
fixes #19000
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Oct 21, 2021
1 parent 5e2b934 commit 261c1cf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/system/memalloc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ when hasAlloc and not defined(js):
##
## See also:
## * `create <#create,typedesc>`_
static:
if sizeof(T) <= 0:
{.fatal: "createU does not support types T where sizeof(T) == 0".}
cast[ptr T](alloc(T.sizeof * size))

template alloc0*(size: Natural): pointer =
Expand All @@ -141,6 +144,9 @@ when hasAlloc and not defined(js):
##
## The allocated memory belongs to its allocating thread!
## Use `createShared <#createShared,typedesc>`_ to allocate from a shared heap.
static:
if sizeof(T) <= 0:
{.fatal: "create does not support types T where sizeof(T) == 0".}
cast[ptr T](alloc0(sizeof(T) * size))

template realloc*(p: pointer, newSize: Natural): pointer =
Expand Down

0 comments on commit 261c1cf

Please sign in to comment.