On Saturday, 15 August 2015 at 01:13:02 UTC, Adam D. Ruppe wrote:
On Saturday, 15 August 2015 at 01:09:15 UTC, D_Learner wrote:
When writting a pure fucntion involving C non pure functions like
 memcpy() and   memset()

Those functions are pure already, and marked so in the newest dmd (and I think older ones too, though I haven't confirmed.

Your code compiled out of the box for me.

BTW D also has some syntax sugar for them:

arr[start .. end] = 0; // memset those bounds to 0
arr[start .. end] = arr2[start .. end]; // memcpy

You could be surprised am still trying to get my head around this. Considering the code :-

    memcpy(&skip[0], &skip[0]+shift, (m-shift)*(int.sizeof));
    memset(&skip[0]+(m-shift),0, shift*(int.sizeof))

I was thinking conversion would be :-

skip[0 .. size-1] = skip[shift .. size-1 ]; //For the memcpy();
    skip[0 .. size-1] = 0;    //For memset()

But this doesn't seem to work for me as dmd(v2.066.1) gives the "error slice [8..7] exceeds array bounds [0..8]" .Sure am missing something.







Reply via email to