I have a c struct defined as follows:
typedef struct
{
int data_size;
BYTE* data;
} IMAGE;
I have another struct like this
typedef struct
{
int nimages;
IMAGE* images;
} IMGARR
I would like to be able to reallocate images to hold another sizeof(IMAGE) structure so I can just keep an array of images with their binary data.
Here is what I've been trying
IMGARR* image_temp = imgarr->images; //store pointer
image_temp = realloc(&image_temp, (imgarr->nimages + 1) * sizeof(IMAGE)); //realloc memory
memcpy(&imgarr->images[imgarr->nimages], &my_new_image, sizeof(IMAGE));
This doesn't seem to work at all. I seem to have become really rusty at c memory allocation. Any help would be awesome!
imgarrof typeIMGARR*? Isimgarr-imagesof typeIMAGE*?