private
{
- import stdc.stdlib;
- import stdc.string;
- import stdc.stdarg;
- debug(PRINTF) import stdc.stdio;
+ import core.stdc.stdlib;
+ import core.stdc.string;
+ import core.stdc.stdarg;
+ debug(PRINTF) import core.stdc.stdio;
}
extern (C) size_t gc_sizeOf( void* p );
extern (C) BlkInfo gc_query( void* p );
- extern (C) void onFinalizeError( ClassInfo c, Exception e );
+ extern (C) void onFinalizeError( ClassInfo c, Throwable e );
extern (C) void onOutOfMemoryError();
extern (C) void _d_monitordelete(Object h, bool det = true);
}
+/**
+ *
+ */
+extern (C) void* _d_allocmemory(size_t sz)
+{
+ return gc_malloc(sz);
+}
+
+
/**
*
*/
/**
- *
+ * This function has been replaced by _d_delarray_t
*/
-void* _d_allocmemory(size_t nbytes)
+extern (C) void _d_delarray(Array *p)
{
- return gc_malloc(nbytes);
+ if (p)
+ {
+ assert(!p.length || p.data);
+
+ if (p.data)
+ gc_free(p.data);
+ p.data = null;
+ p.length = 0;
+ }
}
/**
*
*/
-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;
}
if ((cast(void**)p)[1]) // if monitor is not null
_d_monitordelete(cast(Object)p, det);
}
- catch (Exception e)
+ catch (Throwable e)
{
onFinalizeError(**pc, e);
}