Good practice to deteirmne texture size in cpp top

Hi
What is good practice to change on the fly the texture size from the top settings ?
to asffect he cpp top ?

I wish to do condition in the execute function that checks if the resolution changed
in the cpp top settings - if it does , update the texture size accordingly.

Also
how do i get pixel ( include all channels ) byte size ?
so far I do somthjing like this :

uint32_t imageByteSize = output->width * output->height * (output->redBits * 0.125) * 4;
rgbaIn = (unsigned char*) malloc(imageByteSize);

Not sure,
but so far the cpp top does not act according its settings
even when return false in getOutputFormat fucntion…
it always stays 256X256