chiark / gitweb /
rsa.c: Replace the magic length 1024 with a (larger) constant.
[secnet.git] / util.c
diff --git a/util.c b/util.c
index 086c23440ffd1fc592495b5235277a9e104f063d..f5f3d75aa81c891ef04368d739d2d488120375a1 100644 (file)
--- a/util.c
+++ b/util.c
@@ -301,6 +301,18 @@ void buffer_new(struct buffer_if *buf, int32_t len)
     buf->base=safe_malloc(len,"buffer_new");
 }
 
+void buffer_copy(struct buffer_if *dst, const struct buffer_if *src)
+{
+    if (dst->len < src->len) {
+       dst->base=realloc(dst->base,src->len);
+       if (!dst->base) fatal_perror("buffer_copy");
+       dst->len = src->len;
+    }
+    dst->start = dst->base + (src->start - src->base);
+    dst->size = src->size;
+    memcpy(dst->start, src->start, dst->size);
+}
+
 static list_t *buffer_apply(closure_t *self, struct cloc loc, dict_t *context,
                            list_t *args)
 {