Re: convert int[][] to int**

2014-02-21 Thread Chris Williams
On Friday, 21 February 2014 at 19:13:13 UTC, Chris Williams wrote: On Thursday, 20 February 2014 at 17:02:15 UTC, Dicebot wrote: You can't do it without allocation because memory layout is different for int** and int[][] in D - are.ptr in latter points to slice struct (pointer+length) as oppose

Re: convert int[][] to int**

2014-02-21 Thread Chris Williams
On Thursday, 20 February 2014 at 17:02:15 UTC, Dicebot wrote: You can't do it without allocation because memory layout is different for int** and int[][] in D - are.ptr in latter points to slice struct (pointer+length) as opposed to raw pointer in former. You should only have to copy the top

Re: convert int[][] to int**

2014-02-20 Thread Dicebot
On Thursday, 20 February 2014 at 16:55:51 UTC, Andrea Fontana wrote: On Thursday, 20 February 2014 at 16:47:43 UTC, bearophile wrote: Andrea Fontana: I have a C api that need a int** params that represent a int[][]. How can I convert from d to c to pass it? For simple arrays, array.ptr seems

Re: convert int[][] to int**

2014-02-20 Thread bearophile
Andrea Fontana: Ok, so it seems there's no "built-in" ways... Yeah, and this is a very good thing :-) Bye, bearophile

Re: convert int[][] to int**

2014-02-20 Thread Andrea Fontana
On Thursday, 20 February 2014 at 16:47:43 UTC, bearophile wrote: Andrea Fontana: I have a C api that need a int** params that represent a int[][]. How can I convert from d to c to pass it? For simple arrays, array.ptr seems to work... One way to do it (untested): int** pp = myDArray.map!(a

Re: convert int[][] to int**

2014-02-20 Thread bearophile
Andrea Fontana: I have a C api that need a int** params that represent a int[][]. How can I convert from d to c to pass it? For simple arrays, array.ptr seems to work... One way to do it (untested): int** pp = myDArray.map!(a => a.ptr).array.ptr; Bye, bearophile

convert int[][] to int**

2014-02-20 Thread Andrea Fontana
I'm pretty sure I've just read about this, but search engines are not useful in this case. I have a C api that need a int** params that represent a int[][]. How can I convert from d to c to pass it? For simple arrays, array.ptr seems to work...