[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Thu May 15 04:50:03 MDT 2014
The branch, master has been updated
via 593c810 talloc: Tune talloc_vasprintf
from 5d99835 s3:vfs_gpfs: increase log level for EPERM and EACCES errors in gpfs_get_xattr()
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 593c8103af5a5ed6b3c915369fed5b90efb42c25
Author: Volker Lendecke <vl at samba.org>
Date: Fri Jan 10 10:45:22 2014 +0100
talloc: Tune talloc_vasprintf
vsnprintf is significantly more expensive than memcpy. For the
common case where the string we print is less than a kilobyte, avoid
the second vsnprintf.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Thu May 15 12:49:14 CEST 2014 on sn-devel-104
-----------------------------------------------------------------------
Summary of changes:
lib/talloc/talloc.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 1cb4d7d..2a5406e 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -2356,11 +2356,11 @@ _PUBLIC_ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
int len;
char *ret;
va_list ap2;
- char c;
+ char buf[1024];
/* this call looks strange, but it makes it work on older solaris boxes */
va_copy(ap2, ap);
- len = vsnprintf(&c, 1, fmt, ap2);
+ len = vsnprintf(buf, sizeof(buf), fmt, ap2);
va_end(ap2);
if (unlikely(len < 0)) {
return NULL;
@@ -2369,9 +2369,13 @@ _PUBLIC_ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
ret = (char *)__talloc(t, len+1);
if (unlikely(!ret)) return NULL;
- va_copy(ap2, ap);
- vsnprintf(ret, len+1, fmt, ap2);
- va_end(ap2);
+ if (len < sizeof(buf)) {
+ memcpy(ret, buf, len+1);
+ } else {
+ va_copy(ap2, ap);
+ vsnprintf(ret, len+1, fmt, ap2);
+ va_end(ap2);
+ }
_talloc_set_name_const(ret, ret);
return ret;
--
Samba Shared Repository
More information about the samba-cvs
mailing list