It doesn't matter the order.
If you reallocate malloc to a pointer of memory, you have to do the opposite of free. I think this is your intention.
For example, if you assign A to malloc and B of A->B to malloc, you should free B and then free A. If A is free, B remains in memory, but B is not able to free B because B's address is unknown (because it flew away).
© 2025 OneMinuteCode. All rights reserved.