// No luck still, allocate new memory
cell = cast(Cell*) cstdlib.malloc(size + Cell.sizeof);
+ cell.capacity = 0; // so we can later tell it's new
if (cell)
goto success;
*/
void* calloc(size_t size, uint attr=0)
{
+ if (size == 0)
+ return null;
+
void* ptr = this.malloc(size, attr);
- if (ptr is null)
- onOutOfMemoryError();
- else
+ if (ptr !is null) // in case onOutOfMemoryError didn't throw
cstring.memset(ptr, 0, size);
return ptr;