I'm having trouble working with size_t* and uint32_t*
I have a program that has something like
int main ()
{
size_t out_length;
.
.
.
func_1(param_1, ..., &out_length);
out_length > some_numberl;
}
func_1(param_1, ... , size_t *length)
{
.
.
.
*length = 0;
.
.
*length = to_some_unsigned_number;
}
As it is calling func_1(); in main works fine, but now I have to call func_1(); inside another function that looks like this
func_2(param_1, ...,uint32_t* output_length)
{
}
so the program looks like this now
int main ()
{
size_t out_length;
.
.
.
func_2(param_1, ..., &out_length);
out_length > some_number;
}
func_2(param_1, ...,uint32_t* output_length)
{
func_1(param_1, ... ,output_length);
//stuff
}
func_1(param_1, ... , size_t *length)
{
.
.
.
*length = 0;
.
.
*length = to_some_unsigned_number;
}
so my question is how to appropriately obtain the value of output_length. I currently read 0s.
I'll appreciate if someone could point me to the right direction.
You cannot store the
size_tvalue returned byf1directly into theuint32_tvariable pointed to by thef2argument, since the types are different, and the sizes can be different, too. Instead, use an intermediate local inf2, which also gives a chance to test for out of range conditions. Same goes for theuint32_tvalue returned byf2tomain, just in the opposite direction.