Re: Converting void* to D array

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 8:35 AM, CraigDillabaugh wrote: On Wednesday, 15 April 2015 at 11:18:03 UTC, Steven Schveighoffer wrote: immutable blocksize = GByte.sizeof * x_block_size * y_block_size; auto buffer = malloc(blocksize)[0..blocksize]; Also, you don't need to cast pointers to void *. Should be able

Re: Converting void* to D array

2015-04-15 Thread CraigDillabaugh via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 11:18:03 UTC, Steven Schveighoffer wrote: On 4/15/15 12:47 AM, Daniel Kozak wrote: On Wednesday, 15 April 2015 at 04:43:39 UTC, Daniel Kozák wrote: On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com

Re: Converting void* to D array

2015-04-15 Thread CraigDillabaugh via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 11:18:03 UTC, Steven Schveighoffer wrote: clip Depends on what GByte is. If it doesn't contain pointers (I'm assuming its probably ubyte?), then it won't be scanned. clip -Steve Yes, GByte is an alias for ubyte.

Re: Converting void* to D array

2015-04-15 Thread CraigDillabaugh via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 14:02:38 UTC, Steven Schveighoffer wrote: On 4/15/15 8:35 AM, CraigDillabaugh wrote: On Wednesday, 15 April 2015 at 11:18:03 UTC, Steven Schveighoffer wrote: immutable blocksize = GByte.sizeof * x_block_size * y_block_size; auto buffer =

Re: Converting void* to D array

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 11:02 AM, CraigDillabaugh wrote: Nice. Thanks. I didn't realize you can slice a bare pointer like that. Does druntime have any way of making sure that is safe, or are you on your own? No, druntime cannot know what the pointer actually points at. This would not work in @safe

Re: Converting void* to D array

2015-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/15 12:47 AM, Daniel Kozak wrote: On Wednesday, 15 April 2015 at 04:43:39 UTC, Daniel Kozák wrote: On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi. I want to call a C library function that returns a data buffer as

Re: Converting void* to D array

2015-04-14 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 04:43:39 UTC, Daniel Kozák wrote: On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting

Re: Converting void* to D array

2015-04-14 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting void* into something I can process in D? //I have the

Re: Converting void* to D array

2015-04-14 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 04:43:39 UTC, Daniel Kozák wrote: On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting

Converting void* to D array

2015-04-14 Thread Craig Dillabaugh via Digitalmars-d-learn
Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting void* into something I can process in D? //I have the following function from the GDAL C library. extern(C) CPLErr GDALReadBlock( GDALRasterBandH, int, int, void* ); So I have

Re: Converting void* to D array

2015-04-14 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting void* into something I can process in D? //I have the