It's easiest to pass the old pointer to myfunction(), and have it return the new pointer (which might be the same as the old, if realloc() managed to grow the area in-place).
Note that realloc() can fail, in that case you don't want to lose track of the old memory which is still allocated so overwriting the same pointer without checking is a bad idea.