regedit: Use a helper function to free allocated memory.