aboutsummaryrefslogtreecommitdiff
path: root/src/rps/rps-test_util.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-03-21 07:56:51 +0100
committerJulius Bünger <buenger@mytum.de>2018-03-21 10:12:30 +0100
commit9d068580565b7ad49f5db5e3dae7b538f0f9bd5b (patch)
tree3727e33407c8e4457bf6808c05b5c6656f1c8bf4 /src/rps/rps-test_util.c
parent29d419cdf833f2b2115250373c1a015f12a017e1 (diff)
rps profiler: log view sizes
Diffstat (limited to 'src/rps/rps-test_util.c')
-rw-r--r--src/rps/rps-test_util.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 882f945c93..e492b76b76 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -43,6 +43,7 @@ to_file_ (char *file_name, char *line)
{
struct GNUNET_DISK_FileHandle *f;
char output_buffer[512];
+ char *output_buffer_p;
//size_t size;
int size;
size_t size2;
@@ -62,8 +63,14 @@ to_file_ (char *file_name, char *line)
file_name);
return;
}
- size = GNUNET_snprintf (output_buffer,
- sizeof (output_buffer),
+ if (512 < strlen (line) + 18)
+ {
+ output_buffer_p = GNUNET_malloc ((strlen (line) + 18) * sizeof (char));
+ } else {
+ output_buffer_p = &output_buffer[0];
+ }
+ size = GNUNET_snprintf (output_buffer_p,
+ sizeof (output_buffer_p),
"%llu %s\n",
GNUNET_TIME_absolute_get ().abs_value_us,
line);
@@ -75,7 +82,7 @@ to_file_ (char *file_name, char *line)
return;
}
- size2 = GNUNET_DISK_file_write (f, output_buffer, size);
+ size2 = GNUNET_DISK_file_write (f, output_buffer_p, size);
if (size != size2)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -90,6 +97,11 @@ to_file_ (char *file_name, char *line)
return;
}
+ if (512 < strlen (line) + 18)
+ {
+ GNUNET_free (output_buffer_p);
+ }
+
if (GNUNET_YES != GNUNET_DISK_file_close (f))
LOG (GNUNET_ERROR_TYPE_WARNING,
"Unable to close file\n");