Can we just have struct inheritence already?

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu Jun 13 10:48:34 UTC 2019


On Thursday, 13 June 2019 at 10:25:02 UTC, aliak wrote:
> If you try to malloc some number of zero-sized types naively, 
> you'll pass an allocation size of 0 to the allocator, which is 
> implementation-defined at best. Also you want to avoid 
> allocating these things anyway!

On 64 bit architectures you probably could write a custom malloc 
that will return a unique address outside the memory map for 
0-sized allocations. It would have to mark it in a bitmap so that 
it could be freed.

*shrugs*

But, I doubt that people actually do this often. Allocating 4-8 
bytes probably would be ok, so you could just redefine malloc as 
malloc(max(allocationsize,8)).




More information about the Digitalmars-d mailing list