more style fixes
authorChristian Grothoff <christian@grothoff.org>
Thu, 21 Feb 2019 11:02:14 +0000 (12:02 +0100)
committerChristian Grothoff <christian@grothoff.org>
Thu, 21 Feb 2019 11:02:14 +0000 (12:02 +0100)
src/rps/gnunet-service-rps.c

index ccf54d1e235ed0092244107b12e94c2becdab92b..375c93a67c77958136163e2078b7c9f59ef5cb7a 100644 (file)
@@ -2846,19 +2846,15 @@ new_sub (const struct GNUNET_HashCode *hash,
   {
     char *tmp_filename_valid_peers;
     char str_hash[105];
-    uint32_t len_filename_valid_peers;
-
-    (void) GNUNET_snprintf (str_hash, 105, GNUNET_h2s_full (hash));
-    tmp_filename_valid_peers = GNUNET_strdup (sub->filename_valid_peers);
-    GNUNET_free (sub->filename_valid_peers);
-    len_filename_valid_peers = strlen (tmp_filename_valid_peers) + 105; /* Len of full hash + 1 */
-    sub->filename_valid_peers = GNUNET_malloc (len_filename_valid_peers);
-    strncat (sub->filename_valid_peers,
-             tmp_filename_valid_peers,
-             len_filename_valid_peers);
-    strncat (sub->filename_valid_peers,
-             str_hash,
-             len_filename_valid_peers);
+
+    GNUNET_snprintf (str_hash,
+                    strlen (str_hash),
+                    GNUNET_h2s_full (hash));
+    tmp_filename_valid_peers = sub->filename_valid_peers;
+    GNUNET_asprintf (&sub->filename_valid_peers,
+                    "%s%s",
+                    tmp_filename_valid_peers,
+                    str_hash);
     GNUNET_free (tmp_filename_valid_peers);
   }
   sub->peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO);