betterC: new operator

Petar Petar
Tue Nov 24 11:01:55 UTC 2020


On Sunday, 22 November 2020 at 16:58:03 UTC, Basile B. wrote:
> [..]
>
> But that's a good start to get things done more properly

Awesome work! I knew it must be possible, but I never tried 
implementing that.

Small bug fix:

> void** entries = cast(void**) malloc(members.length + 1);

Here you're allocating space for (members.length + 1) bytes, 
while I suppose you actually want to allocate this number of vtbl 
slots (each being void*.sizeof bytes):

> auto entries = cast(const(void*)*) malloc((members.length + 1) 
> * (void*).sizeof);

I also added `const` for good measure, as the code that the 
function pointers point to is stored in read-only memory (AFAIK).


More information about the Digitalmars-d mailing list