summaryrefslogtreecommitdiff
path: root/bufaux.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2008-05-19 14:59:37 +1000
committerDamien Miller <djm@mindrot.org>2008-05-19 14:59:37 +1000
commitdb255cad0531047a3e35a95af74ad2e03b054412 (patch)
tree7452c18135999436612dcb4e6e7d9c9f2abfe90f /bufaux.c
parente9890193032b4bba7afa40d4fc003bbf629afba2 (diff)
downloadopenssh-git-db255cad0531047a3e35a95af74ad2e03b054412.tar.gz
- 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@
Diffstat (limited to 'bufaux.c')
-rw-r--r--bufaux.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/bufaux.c b/bufaux.c
index cbdc22c6..f0336399 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 @@ buffer_get_string(Buffer *buffer, u_int *length_ptr)
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.
*/