So far as correctness goes: Nearly anything you prefer, supplied you are taking care never to obtain details just after freeing it. The obvious most straightforward strategy (which I will not point out explicitly simply because this appears to be like kinda like homework :-) however it's That which you'd do when you wished to compose as minor code