correct usage of free for strdup memory