Hi,
I am trying to use a program that has the a variable of type void** but I don't understand well what is meaning of this.
Does any knows what is the meaning of the following code?
I specifically would like to know how many bytes are allocated in pdata and data.(and the reason)
Al least one of them is data of pixels (since imgtmp is an image structure)
imgtmp->pdata is void** type and
imgtmp->data is void* type,
I replaced some vars for constants as you can see.
This a fragment of code that creates an image structure.
Code:
void **pdata;
if ( NULL == (pdata = (void **)malloc(sizeof(void *) * 4)) ){ //4 is the image height
//free data, function failed
return();
}
imgtmp->pdata = pdata;
if ( NULL == (imgtmp->data = (char *)malloc(12)) ){ //12 is image hole buffer size
//free data, function failed
return();
}
for (int i=0 ; i<4 ; i++ ) //4 is the image height
pdata[i] = (void *)(imgtmp->data + i*3); //3 is bytes per line in the image
As you can see I am trying to allocate a 3*4 image.
BTW: I tried sizeof(void *) and it gives me a long unsigned 8, so pdata should be 32, but is always 8 , why?