Merge branch 'master' of ssh://gnunet.org/gnunet
[oweals/gnunet.git] / src / util / bio.c
index 522c28cf811ed2e908daf9c916b08bf4f4045eba..08e30dc01ae8c3125ed3f743e390d1668064de65 100644 (file)
  * @author Christian Grothoff
  */
 #include "platform.h"
-#include "gnunet_bio_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
+
+#define LOG(kind,...) GNUNET_log_from (kind, "util-bio",__VA_ARGS__)
+
+#ifndef PATH_MAX
+/**
+ * Assumed maximum path length (for source file names).
+ */
+#define PATH_MAX 4096
+#endif
 
-#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__)
 
 /**
  * Size for I/O buffers.
@@ -155,7 +162,7 @@ GNUNET_BIO_read (struct GNUNET_BIO_ReadHandle *h,
     {
       if (min > len - pos)
         min = len - pos;
-      memcpy (&dst[pos], &h->buffer[h->pos], min);
+      GNUNET_memcpy (&dst[pos], &h->buffer[h->pos], min);
       h->pos += min;
       pos += min;
     }
@@ -205,7 +212,7 @@ GNUNET_BIO_read_fn (struct GNUNET_BIO_ReadHandle *h,
                     void *result,
                     size_t len)
 {
-  char what[1024];
+  char what[PATH_MAX + 1024];
 
   GNUNET_snprintf (what, sizeof (what), "%s:%d", file, line);
   return GNUNET_BIO_read (h, what, result, len);
@@ -481,7 +488,7 @@ GNUNET_BIO_write (struct GNUNET_BIO_WriteHandle *h, const void *buffer,
     min = h->size - h->have;
     if (min > n - pos)
       min = n - pos;
-    memcpy (&h->buffer[h->have], &src[pos], min);
+    GNUNET_memcpy (&h->buffer[h->have], &src[pos], min);
     pos += min;
     h->have += min;
     if (pos == n)