Converting void* to D array
Craig Dillabaugh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Apr 14 21:24:20 PDT 2015
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 (GByte is defined in the GDAL library):
void* buffer = malloc( GByte.sizeof * x_block_size * y_block_size
);
I fill the buffer (and ignore any errors :o)
GDALReadBlock( AGDALRasterBandHInstance, xblock, yblock, buffer );
Now, how can I access the data in buffer?
More information about the Digitalmars-d-learn
mailing list