Safely extend the size of a malloced memory block after realloc
Benjamin Thaut via Digitalmars-d
digitalmars-d at puremagic.com
Mon Aug 17 22:54:38 PDT 2015
On Monday, 17 August 2015 at 20:33:45 UTC, welkam wrote:
> I might be wrong, but he should worry about GC before he
> removes that memory range from GC managed list not after. And
> his code smells to me. He gives full memory control to GC, but
> then wants to take it away, fiddle and give it back. I would
> allocate more than I need to so avoiding a need to extend the
> memory. If not then either allocate new chunk of memory, copy
> data and forget about old one or have a data structure where I
> could add new chunks of memory.
> Its best to minimise system calls such as malloc and similar
> because they hit OS and slow down execution.
The memory in question is never controlled by the GC. But it may
contain pointers into GC memory. You need to update your view on
what addRange and removeRange does. Also when you bind a
different language to D you don't have the option to change the
code, you have to work with whats already there.
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d
mailing list