You're regularly going to come across problems like this if you confuse yourself with too much indirection. Much better is to change to:
void retsom(char ** page)
{
char * newpage = malloc(10);
if ( !newpage ) {
perror("couldn't allocate memory");
exit(EXIT_FAILURE);
}
newpage[0] = 'a';
newpage[1] = 'b';
*page = newpage;
}
and avoid the issue entirely. This also has the benefit that if you want to do something other than terminate in the event of malloc() or other failure, you haven't yet overwritten the pointer the caller supplied, so your function is better behaved in exceptional conditions.
Note that sizeof(char) is always 1 by definition, and therefore redundant, and that you shouldn't cast the return from malloc() in C. malloc() can also fail, so you should check its return value.
'\0'. It would be safer to use*page = calloc(10, sizeof **page);retsomallocates 10 chars withmalloc. These chars are uninitialized and may contain random values.retsomonly initializes the first 2 chars to'a'and'b', leaving the rest in a random state. This is error prone, leading to spurious, non reproducible bugs. The cost ofcallocversusmallocis negligible. The benefit is the initialization to 0 of the allocated memory block.