[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r37795 - gnunet/src/namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r37795 - gnunet/src/namestore |
Date: |
Fri, 26 Aug 2016 14:48:07 +0200 |
Author: grothoff
Date: 2016-08-26 14:48:07 +0200 (Fri, 26 Aug 2016)
New Revision: 37795
Modified:
gnunet/src/namestore/plugin_namestore_flat.c
Log:
fix memory leak and unnecessary allocations
Modified: gnunet/src/namestore/plugin_namestore_flat.c
===================================================================
--- gnunet/src/namestore/plugin_namestore_flat.c 2016-08-26 12:43:15 UTC
(rev 37794)
+++ gnunet/src/namestore/plugin_namestore_flat.c 2016-08-26 12:48:07 UTC
(rev 37795)
@@ -142,10 +142,10 @@
size_t key_len;
struct GNUNET_HashCode hkey;
struct GNUNET_DISK_FileHandle *fh;
- struct FlatFileEntry *entry;
+ struct FlatFileEntry *entry;
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
+ GNUNET_CONFIGURATION_get_value_filename (plugin->cfg,
"namestore-flat",
"FILENAME", &afsdir))
{
@@ -243,7 +243,7 @@
record_data_size = GNUNET_STRINGS_base64_decode (record_data_b64,
strlen
(record_data_b64),
&record_data);
- entry->record_data =
+ entry->record_data =
GNUNET_malloc (sizeof (struct GNUNET_GNSRECORD_Data) *
entry->record_count);
if (GNUNET_OK != GNUNET_GNSRECORD_records_deserialize (record_data_size,
record_data,
@@ -271,7 +271,7 @@
key_len,
&hkey);
GNUNET_free (key);
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
GNUNET_CONTAINER_multihashmap_put (plugin->hm,
&hkey,
entry,
@@ -301,8 +301,6 @@
struct FlatFileEntry *entry = value;
char *line;
char *zone_private_key;
- char *rvalue;
- char *record_count;
char *record_data_b64;
size_t data_size;
@@ -309,38 +307,34 @@
GNUNET_STRINGS_base64_encode ((char*)entry->private_key,
sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey),
&zone_private_key);
- GNUNET_asprintf (&rvalue, "%lu", entry->rvalue);
- GNUNET_asprintf (&record_count, "%u", entry->record_count);
-
data_size = GNUNET_GNSRECORD_records_get_size (entry->record_count,
entry->record_data);
- char data[data_size];
- if (data_size != GNUNET_GNSRECORD_records_serialize (entry->record_count,
- entry->record_data,
- data_size,
- data))
{
- GNUNET_break (0);
- GNUNET_free (zone_private_key);
- GNUNET_free (rvalue);
- GNUNET_free (record_count);
- return GNUNET_SYSERR;
+ char data[data_size];
+
+ if (data_size !=
+ GNUNET_GNSRECORD_records_serialize (entry->record_count,
+ entry->record_data,
+ data_size,
+ data))
+ {
+ GNUNET_break (0);
+ GNUNET_free (zone_private_key);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_STRINGS_base64_encode (data,
+ data_size,
+ &record_data_b64);
}
- GNUNET_STRINGS_base64_encode (data,
- data_size,
- &record_data_b64);
-
GNUNET_asprintf (&line,
- "%s,%s,%s,%s,%s\n",
+ "%s,%lu,%u,%s,%s\n",
zone_private_key,
- rvalue,
- record_count,
+ entry->rvalue,
+ entry->record_count,
record_data_b64,
entry->label);
-
- GNUNET_free (rvalue);
- GNUNET_free (record_count);
GNUNET_free (record_data_b64);
+ GNUNET_free (zone_private_key);
GNUNET_DISK_file_write (fh,
line,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r37795 - gnunet/src/namestore,
gnunet <=