Commit 64ae53f4 authored by Thomas Guillem's avatar Thomas Guillem

keystore: factor vlc_keystore_release_entry

parent bd17fa57
...@@ -267,6 +267,18 @@ vlc_keystore_entry_set_secret(vlc_keystore_entry *p_entry, ...@@ -267,6 +267,18 @@ vlc_keystore_entry_set_secret(vlc_keystore_entry *p_entry,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static inline void
vlc_keystore_release_entry(vlc_keystore_entry *p_entry)
{
for (unsigned int j = 0; j < KEY_MAX; ++j)
{
free(p_entry->ppsz_values[j]);
p_entry->ppsz_values[j] = NULL;
}
free(p_entry->p_secret);
p_entry->p_secret = NULL;
}
typedef struct vlc_keystore_sys vlc_keystore_sys; typedef struct vlc_keystore_sys vlc_keystore_sys;
struct vlc_keystore struct vlc_keystore
{ {
......
...@@ -360,15 +360,7 @@ Store(vlc_keystore *p_keystore, const char *const ppsz_values[KEY_MAX], ...@@ -360,15 +360,7 @@ Store(vlc_keystore *p_keystore, const char *const ppsz_values[KEY_MAX],
vlc_keystore_entry *p_entry = list_get_entry(p_list, ppsz_values, NULL); vlc_keystore_entry *p_entry = list_get_entry(p_list, ppsz_values, NULL);
if (p_entry) if (p_entry)
{ vlc_keystore_release_entry(p_entry);
free(p_entry->p_secret);
p_entry->p_secret = NULL;
for (unsigned int i = 0; i < KEY_MAX; ++i)
{
free(p_entry->ppsz_values[i]);
p_entry->ppsz_values[i] = NULL;
}
}
else else
{ {
p_entry = list_new_entry(p_list); p_entry = list_new_entry(p_list);
...@@ -441,8 +433,7 @@ Remove(vlc_keystore *p_keystore, const char *const ppsz_values[KEY_MAX]) ...@@ -441,8 +433,7 @@ Remove(vlc_keystore *p_keystore, const char *const ppsz_values[KEY_MAX])
while ((p_entry = list_get_entry(p_list, ppsz_values, &i_index))) while ((p_entry = list_get_entry(p_list, ppsz_values, &i_index)))
{ {
free(p_entry->p_secret); vlc_keystore_release_entry(p_entry);
p_entry->p_secret = NULL;
i_count++; i_count++;
} }
......
...@@ -116,12 +116,7 @@ void ...@@ -116,12 +116,7 @@ void
vlc_keystore_release_entries(vlc_keystore_entry *p_entries, unsigned int i_count) vlc_keystore_release_entries(vlc_keystore_entry *p_entries, unsigned int i_count)
{ {
for (unsigned int i = 0; i < i_count; ++i) for (unsigned int i = 0; i < i_count; ++i)
{ vlc_keystore_release_entry(&p_entries[i]);
vlc_keystore_entry *p_entry = &p_entries[i];
for (unsigned int j = 0; j < KEY_MAX; ++j)
free(p_entry->ppsz_values[j]);
free(p_entry->p_secret);
}
free(p_entries); free(p_entries);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment