using malloc, freeing once