mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Added _d_delarray_t and _d_allocmemory.
This commit is contained in:
parent
faec8478df
commit
840f10020b
1 changed files with 40 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue