svn commit: samba r5937 - in branches/SAMBA_4_0/source/lib/talloc: .
tridge at samba.org
tridge at samba.org
Tue Mar 22 04:22:40 GMT 2005
Author: tridge
Date: 2005-03-22 04:22:39 +0000 (Tue, 22 Mar 2005)
New Revision: 5937
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5937
Log:
- performance improvement to talloc_asprintf_append()
- allow standalone talloc to use gcc printf attributes
Modified:
branches/SAMBA_4_0/source/lib/talloc/talloc.c
branches/SAMBA_4_0/source/lib/talloc/talloc.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.c 2005-03-22 02:23:52 UTC (rev 5936)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.c 2005-03-22 04:22:39 UTC (rev 5937)
@@ -946,16 +946,13 @@
static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
{
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(s);
int len, s_len;
va_list ap2;
VA_COPY(ap2, ap);
- if (s) {
- s_len = strlen(s);
- } else {
- s_len = 0;
- }
+ s_len = tc->size - 1;
len = vsnprintf(NULL, 0, fmt, ap2);
s = talloc_realloc(NULL, s, char, s_len + len+1);
Modified: branches/SAMBA_4_0/source/lib/talloc/talloc.h
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc/talloc.h 2005-03-22 02:23:52 UTC (rev 5936)
+++ branches/SAMBA_4_0/source/lib/talloc/talloc.h 2005-03-22 04:22:39 UTC (rev 5937)
@@ -75,8 +75,16 @@
#endif
#ifndef PRINTF_ATTRIBUTE
+#if (__GNUC__ >= 3)
+/** Use gcc attribute to check printf fns. a1 is the 1-based index of
+ * the parameter containing the format, and a2 the index of the first
+ * argument. Note that some gcc 2.x versions don't handle this
+ * properly **/
+#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
+#else
#define PRINTF_ATTRIBUTE(a1, a2)
#endif
+#endif
/* The following definitions come from talloc.c */
More information about the samba-cvs
mailing list