[vlc-commits] keystore: factor vlc_keystore_release_entry
Thomas Guillem
git at videolan.org
Tue Jan 12 11:55:14 CET 2016
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jan 12 10:24:16 2016 +0100| [64ae53f4ee7f72016687d8876ff6a2b061ac36d4] | committer: Thomas Guillem
keystore: factor vlc_keystore_release_entry
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64ae53f4ee7f72016687d8876ff6a2b061ac36d4
---
include/vlc_keystore.h | 12 ++++++++++++
modules/keystore/plaintext.c | 13 ++-----------
src/misc/keystore.c | 7 +------
3 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/include/vlc_keystore.h b/include/vlc_keystore.h
index 9880441..f8a6ae1 100644
--- a/include/vlc_keystore.h
+++ b/include/vlc_keystore.h
@@ -267,6 +267,18 @@ vlc_keystore_entry_set_secret(vlc_keystore_entry *p_entry,
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;
struct vlc_keystore
{
diff --git a/modules/keystore/plaintext.c b/modules/keystore/plaintext.c
index cf9f338..d2049ff 100644
--- a/modules/keystore/plaintext.c
+++ b/modules/keystore/plaintext.c
@@ -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);
if (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;
- }
- }
+ vlc_keystore_release_entry(p_entry);
else
{
p_entry = list_new_entry(p_list);
@@ -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)))
{
- free(p_entry->p_secret);
- p_entry->p_secret = NULL;
+ vlc_keystore_release_entry(p_entry);
i_count++;
}
diff --git a/src/misc/keystore.c b/src/misc/keystore.c
index 2587bd2..911b9ea 100644
--- a/src/misc/keystore.c
+++ b/src/misc/keystore.c
@@ -116,12 +116,7 @@ void
vlc_keystore_release_entries(vlc_keystore_entry *p_entries, unsigned int i_count)
{
for (unsigned int i = 0; i < i_count; ++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);
- }
+ vlc_keystore_release_entry(&p_entries[i]);
free(p_entries);
}
More information about the vlc-commits
mailing list