Use g_try_malloc/g_free/g_strdup consistently.