Am Sun, 06 Jan 2013 09:43:11 -0800 schrieb Ali Çehreli <[email protected]>:
> > Ali > > P.S. To prove the point that that 4 in the signature has no meaning, > I tested the C function also with the following C program: With C's arrays are pointers thing, that might be true. But the signature (and ffmpeg) documentation suggest that the av_image_alloc function will always write 4 ubyte* pointers to the pointers parameter. So you can't use an array smaller than 4 pointers. You can use more, as it doesn't matter for the ABI, but av_image_alloc will only use 4 pointers. So I'd argue that ((ubyte*)[4])* is better as a type than ubyte** as it allows the D compiler to do more checks. And the Interfacing to C page recommends using ref for static arrays instead of a pointer, as that allows using the code as in C: void av_image_alloc(ref (ubyte*)[4]); (ubyte*)[4] ptr; av_image_alloc(ptr); void av_image_alloc((ubyte*)[4]*); (ubyte*)[4] ptr; av_image_alloc(&ptr); //need & void av_image_alloc(ubyte**); (ubyte*)[3] ptr; ubyte* test; //overwritten, BUG! av_image_alloc(&ptr); //need &, and accepts to small arrays, bug prone
