<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><font class="Apple-style-span" face="Courier">I would basically reduce all alloc functions to</font></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier">extern (C)&nbsp;void*&nbsp;function(</font><span class="Apple-style-span" style="font-family: Courier; ">void* oldP,</span><span class="Apple-style-span" style="font-family: Courier; ">size_t minBytes,&nbsp;</span><span class="Apple-style-span" style="font-family: Courier; ">size_t optimalBytes,</span><span class="Apple-style-span" style="font-family: Courier; ">&nbsp;size_t minAlign,&nbsp;</span><span class="Apple-style-span" style="font-family: Courier; ">TypeInfo,int flags,</span><span class="Apple-style-span" style="font-family: Courier; ">size_t* realSizeInBytes</span><span class="Apple-style-span" style="font-family: Courier; ">) gc_realloc;</span></div><div><span class="Apple-style-span" style="font-family: Courier; "><br></span></div><div><font class="Apple-style-span" face="Courier">if one would like to be a bit less extreme also an alloc function could be added, but I will describe only realloc here.</font></div></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier"><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">Allocation is a "heavy" function, and I don't expect that having less arguments would make it faset.</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">This is the interface functions, wrappers could be offered on the top of this if one prefers calloc,... this is a low level interface of the gc that should be pluggable (at least at link time), so having it simple is an advantage imho.</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">now to the behaviour of the function.</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">If oldP is not null tries to preserve the flags of it (but no guarantee is given, it is ok to use the flags from the typeinfo, this would allow switching from storing flags to typeinfo when enlarging an array).</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">If oldP is null the flags are taken from the TypeInfo.</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">minN gives the minimum number of bytes to allocate, minAlign the minimum aligment requested (this should be equal or larger to the type .alignof, note that I expressely avoid asking the typeinfo for it) One might want a larger alignment that the default for the typeinfo (one could avoid this argument by constructing special typeinfos, but I think that it is better to have it).</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">Typeinfo is always required, and t</font><span class="Apple-style-span" style="font-family: Courier; ">here are two special typeinfos aliases that have addesses 0 and size_t.sizeof and represent ubyte and void (which should be which I don't know).</span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; "><br></span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">The flags are a bit field with</span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">- NoInit (the memory should not be initialized)</span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">- NoMove (the pointer should not be moved: only in place resizes)</span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">- InitMax (as much as possible of the allocated memory should be declared as actively used/initialized)</span></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">The two aliases make it possible to easily use the functions also from C.</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">realSizeInBytes will contain the real allocated size (useful in combination with the InitMax&nbsp;</font><span class="Apple-style-span" style="font-family: Courier; "><span class="Apple-style-span" style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">because then&nbsp;</font></span><span class="Apple-style-span" style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">realSizeInBytes/T.sizeof will be initialized</span></span></span><span class="Apple-style-span" style="font-family: Courier; ">, or when minBytes is different from optimalBytes).</span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">It is an error to use the extra allocated memory without having initialized it</span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; "><br></span></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">I think compatibility with&nbsp;Tango&nbsp;is not important, but being able to build/use druntime standalone is.</span></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier">Some GCs might have more dependencies so continuing the "interface for the runtime"/plugin approach is the way to go</font></div><div style="font-family: Helvetica; "><font class="Apple-style-span" face="Courier"><br></font></div><div style="font-family: Helvetica; "><span class="Apple-style-span" style="font-family: Courier; ">Fawzi</span></div></font></div></font></div></body></html>