Added _d_delarray_t and _d_allocmemory.

This commit is contained in:
Sean Kelly 2008-10-10 21:49:12 +00:00
parent faec8478df
commit 840f10020b

View file

@ -81,6 +81,15 @@ private
}
/**
*
*/
extern (C) void* _d_allocmemory(size_t sz)
{
return gc_malloc(sz);
}
/**
*
*/
@ -397,16 +406,7 @@ struct Array
/**
*
*/
void* _d_allocmemory(size_t nbytes)
{
return gc_malloc(nbytes);
}
/**
*
* This function has been replaced by _d_delarray_t
*/
extern (C) void _d_delarray(Array *p)
{
@ -422,6 +422,36 @@ extern (C) void _d_delarray(Array *p)
}
/**
*
*/
extern (C) void _d_delarray_t(Array *p, TypeInfo ti)
{
if (p)
{
assert(!p.length || p.data);
if (p.data)
{
if (ti)
{
// Call destructors on all the sub-objects
auto sz = ti.tsize();
auto pe = p.data;
auto pend = pe + p.length * sz;
while (pe != pend)
{
pend -= sz;
ti.destroy(pend);
}
}
gc_free(p.data);
}
p.data = null;
p.length = 0;
}
}
/**
*
*/