ret = -EINVAL;
break;
}
- printf("read %s\n", buf);
+ if (babeltrace_debug) {
+ fprintf(stdout, "[debug] metadata packet read: %s\n",
+ buf);
+ }
+
writelen = fwrite(buf, sizeof(char), readlen, out);
if (writelen < readlen) {
ret = -EIO;
int ret;
in = *fp;
+ /*
+ * Using strlen on *buf instead of size of open_memstream
+ * because its size includes garbage at the end (after final
+ * \0). This is the allocated size, not the actual string size.
+ */
out = open_memstream(buf, &size);
if (out == NULL)
return -errno;
fclose(out); /* flush the buffer */
fclose(in);
/* open for reading */
- *fp = fmemopen(*buf, size, "rb");
+ *fp = fmemopen(*buf, strlen(*buf), "rb");
return 0;
}