Communication between D and C with dynamic arrays

seany via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 10 08:37:39 PDT 2014


On Sunday, 10 August 2014 at 15:34:30 UTC, ketmar via 
Digitalmars-d-learn wrote:

> from D side -- yes. just don't store passed pointer on C side, 
> 'cause
> it can be changed on array resize.

Excellent,

So if I have

int [] array;
void * ptr_to_array = &array;

/* populate array here */

C_Function(ptr_to_array);

/* repopulate array here, the pointer itself may change, but the 
variable ptr_to_array will be updated accordingly */


C_Function(ptr_to_array);

I am okey?

Also, similar arguments with structs apply?


More information about the Digitalmars-d-learn mailing list