[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 10/19: make GCPP_2s also return static string
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 10/19: make GCPP_2s also return static string |
Date: |
Sun, 22 Jan 2017 15:23:51 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 568dcc7b48238a0df22707dadb93f0f5b62c06b7
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Jan 22 14:06:35 2017 +0100
make GCPP_2s also return static string
---
src/cadet/gnunet-service-cadet-new_paths.c | 33 +++++++++++++++++++-----------
src/cadet/gnunet-service-cadet-new_paths.h | 4 ++--
2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/cadet/gnunet-service-cadet-new_paths.c
b/src/cadet/gnunet-service-cadet-new_paths.c
index aff46db07..bbe9af8b4 100644
--- a/src/cadet/gnunet-service-cadet-new_paths.c
+++ b/src/cadet/gnunet-service-cadet-new_paths.c
@@ -627,6 +627,7 @@ struct CadetPeer *
GCPP_get_peer_at_offset (struct CadetPeerPath *path,
unsigned int off)
{
+ GNUNET_assert (off < path->entries_length);
return path->entries[off].peer;
}
@@ -637,26 +638,34 @@ GCPP_get_peer_at_offset (struct CadetPeerPath *path,
* @param path path to convert
* @return string, to be freed by caller (unlike other *_2s APIs!)
*/
-char *
+const char *
GCPP_2s (struct CadetPeerPath *path)
{
- char *s;
- char *old;
+ static char buf[2048];
+ size_t off;
+ const unsigned int max_plen = sizeof(buf) / 5 - 2; /* 5 characters per entry
*/
- old = GNUNET_strdup ("");
+ off = 0;
for (unsigned int i = 0;
i < path->entries_length;
i++)
{
- GNUNET_asprintf (&s,
- "%s %s",
- old,
- GNUNET_i2s (GCP_get_id (GCPP_get_peer_at_offset (path,
- i))));
- GNUNET_free_non_null (old);
- old = s;
+ if ( (path->entries_length > max_plen) &&
+ (i == max_plen / 2) )
+ off += GNUNET_snprintf (&buf[off],
+ sizeof (buf) - off,
+ "... ");
+ if ( (path->entries_length > max_plen) &&
+ (i > max_plen / 2) &&
+ (i < path->entries_length - max_plen / 2) )
+ continue;
+ off += GNUNET_snprintf (&buf[off],
+ sizeof (buf) - off,
+ "%s ",
+ GNUNET_i2s (GCP_get_id (GCPP_get_peer_at_offset
(path,
+
i))));
}
- return old;
+ return buf;
}
diff --git a/src/cadet/gnunet-service-cadet-new_paths.h
b/src/cadet/gnunet-service-cadet-new_paths.h
index 5714368c7..7310d75e6 100644
--- a/src/cadet/gnunet-service-cadet-new_paths.h
+++ b/src/cadet/gnunet-service-cadet-new_paths.h
@@ -173,9 +173,9 @@ GCPP_get_peer_at_offset (struct CadetPeerPath *path,
* Convert a path to a human-readable string.
*
* @param path path to convert
- * @return string, to be freed by caller (unlike other *_2s APIs!)
+ * @return string, statically allocated
*/
-char *
+const char *
GCPP_2s (struct CadetPeerPath *p);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (a225f5848 -> 4c56d5a0f), gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 05/19: only send CHANNEL_DESTROY message if we at least send the CHANNEL_CREATE message, and not if the tunnel never went up in the first place, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 08/19: allow NULL argument for GNUNET_i2s(), gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 03/19: improve logging, log before doing, not after, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 01/19: optimize startup sequence for when we execute first DHT PUTs, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 11/19: fix buffer size, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 04/19: fix startup interaction between channel and tunnel to not send CHANNEL_OPEN until tunnel is in KEY_OK state, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 18/19: nicer logging, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 10/19: make GCPP_2s also return static string,
gnunet <=
- [GNUnet-SVN] [gnunet] 12/19: fix a few off-by-ones, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 02/19: do not run upnpc during tests, produces unnecessary errors if not available, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 16/19: nicer order of LOG statements, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 13/19: properly launch DHT GETs based on need for paths, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 17/19: must delay iteration over paths until later, as we may be right now creating a connection, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 19/19: must not move location of -struct CadetPeerPathEntry- in memory when growing path length as those structs are also referenced from a DLL, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 07/19: introcude GNUNET_i2s2(), gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 14/19: fix indentation, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 15/19: minor cleanup, gnunet, 2017/01/22
- [GNUnet-SVN] [gnunet] 09/19: more logging for cadet-core subsystem, gnunet, 2017/01/22