As far as correctness goes: Something you prefer, provided you take care to not obtain details just after freeing it. The obvious most basic solution (which I will not likely point out explicitly simply because this seems to be kinda like homework :-) nonetheless it's Everything you'd do should you wished to publish as small code as you possibly ca