Different behaviour of new and malloc
Namespace
rswhite4 at googlemail.com
Sun Apr 14 05:02:59 PDT 2013
It seems that no content is copied with memcpy if I allocate with
new.
The memory is nulled.
If I allocate with GC.malloc or with .dup I get the correct
content.
That seems like a bug. And I cannot give you an simple example
because my code works together with derelict etc. Would be too
much work to create an simple example.
The mysterious thing is:
I store the pixel into a file. If I store the original pixel I
get only the correct output, if I don't use the allocations of
newPixel with new.
If I use
ubyte[] newPixel = new ubyte[size];
The original pixel memory is nulled. That is the explanation why
memcpy seems not to work: memcpy works but the original pixel is
nulled so nothing is copied. But that is weird...
More information about the Digitalmars-d-learn
mailing list