diff options
Diffstat (limited to 'src/omemo/store.c')
-rw-r--r-- | src/omemo/store.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/omemo/store.c b/src/omemo/store.c index 3825c95d..08291460 100644 --- a/src/omemo/store.c +++ b/src/omemo/store.c @@ -143,11 +143,9 @@ store_session(const signal_protocol_address* address, signal_buffer* buffer = signal_buffer_create(record, record_len); g_hash_table_insert(device_store, GINT_TO_POINTER(address->device_id), buffer); - char* record_b64 = g_base64_encode(record, record_len); - char* device_id = g_strdup_printf("%d", address->device_id); + auto_gchar gchar* record_b64 = g_base64_encode(record, record_len); + auto_gchar gchar* device_id = g_strdup_printf("%d", address->device_id); g_key_file_set_string(omemo_sessions_keyfile(), address->name, device_id, record_b64); - free(device_id); - g_free(record_b64); omemo_sessions_keyfile_save(); @@ -187,9 +185,8 @@ delete_session(const signal_protocol_address* address, void* user_data) g_hash_table_remove(device_store, GINT_TO_POINTER(address->device_id)); - char* device_id_str = g_strdup_printf("%d", address->device_id); + auto_gchar gchar* device_id_str = g_strdup_printf("%d", address->device_id); g_key_file_remove_key(omemo_sessions_keyfile(), address->name, device_id_str, NULL); - g_free(device_id_str); omemo_sessions_keyfile_save(); return SG_SUCCESS; @@ -238,11 +235,9 @@ store_pre_key(uint32_t pre_key_id, uint8_t* record, size_t record_len, g_hash_table_insert(pre_key_store, GINT_TO_POINTER(pre_key_id), buffer); /* Long term storage */ - char* pre_key_id_str = g_strdup_printf("%d", pre_key_id); - char* record_b64 = g_base64_encode(record, record_len); + auto_gchar gchar* pre_key_id_str = g_strdup_printf("%d", pre_key_id); + auto_gchar gchar* record_b64 = g_base64_encode(record, record_len); g_key_file_set_string(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, pre_key_id_str, record_b64); - g_free(pre_key_id_str); - g_free(record_b64); omemo_identity_keyfile_save(); @@ -265,9 +260,8 @@ remove_pre_key(uint32_t pre_key_id, void* user_data) int ret = g_hash_table_remove(pre_key_store, GINT_TO_POINTER(pre_key_id)); /* Long term storage */ - char* pre_key_id_str = g_strdup_printf("%d", pre_key_id); + auto_gchar gchar* pre_key_id_str = g_strdup_printf("%d", pre_key_id); g_key_file_remove_key(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, pre_key_id_str, NULL); - g_free(pre_key_id_str); omemo_identity_keyfile_save(); @@ -306,11 +300,9 @@ store_signed_pre_key(uint32_t signed_pre_key_id, uint8_t* record, g_hash_table_insert(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id), buffer); /* Long term storage */ - char* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); - char* record_b64 = g_base64_encode(record, record_len); + auto_gchar gchar* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); + auto_gchar gchar* record_b64 = g_base64_encode(record, record_len); g_key_file_set_string(omemo_identity_keyfile(), OMEMO_STORE_GROUP_SIGNED_PREKEYS, signed_pre_key_id_str, record_b64); - g_free(signed_pre_key_id_str); - g_free(record_b64); omemo_identity_keyfile_save(); @@ -333,9 +325,8 @@ remove_signed_pre_key(uint32_t signed_pre_key_id, void* user_data) int ret = g_hash_table_remove(signed_pre_key_store, GINT_TO_POINTER(signed_pre_key_id)); /* Long term storage */ - char* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); + auto_gchar gchar* signed_pre_key_id_str = g_strdup_printf("%d", signed_pre_key_id); g_key_file_remove_key(omemo_identity_keyfile(), OMEMO_STORE_GROUP_PREKEYS, signed_pre_key_id_str, NULL); - g_free(signed_pre_key_id_str); omemo_identity_keyfile_save(); @@ -393,11 +384,9 @@ save_identity(const signal_protocol_address* address, uint8_t* key_data, g_hash_table_insert(trusted, GINT_TO_POINTER(address->device_id), buffer); /* Long term storage */ - char* key_b64 = g_base64_encode(key_data, key_len); - char* device_id = g_strdup_printf("%d", address->device_id); + auto_gchar gchar* key_b64 = g_base64_encode(key_data, key_len); + auto_gchar gchar* device_id = g_strdup_printf("%d", address->device_id); g_key_file_set_string(omemo_trust_keyfile(), address->name, device_id, key_b64); - g_free(device_id); - g_free(key_b64); omemo_trust_keyfile_save(); |