- markus@cvs.openbsd.org 2008/05/08 06:59:01
     [bufaux.c buffer.h channels.c packet.c packet.h]
     avoid extra malloc/copy/free when receiving data over the net;
     ~10% speedup for localhost-scp; ok djm@
diff --git a/bufaux.c b/bufaux.c
index cbdc22c..f033639 100644
--- a/bufaux.c
+++ b/bufaux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bufaux.c,v 1.44 2006/08/03 03:34:41 deraadt Exp $ */
+/* $OpenBSD: bufaux.c,v 1.45 2008/05/08 06:59:01 markus Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -197,6 +197,22 @@
 	return (ret);
 }
 
+void *
+buffer_get_string_ptr(Buffer *buffer, u_int *length_ptr)
+{
+	void *ptr;
+	u_int len;
+
+	len = buffer_get_int(buffer);
+	if (len > 256 * 1024)
+		fatal("buffer_get_string_ptr: bad string length %u", len);
+	ptr = buffer_ptr(buffer);
+	buffer_consume(buffer, len);
+	if (length_ptr)
+		*length_ptr = len;
+	return (ptr);
+}
+
 /*
  * Stores and arbitrary binary string in the buffer.
  */