svn commit: samba r19909 - in branches/SAMBA_4_0/source/lib/ldb/common: .

idra at samba.org idra at samba.org
Sun Nov 26 21:49:25 GMT 2006


Author: idra
Date: 2006-11-26 21:49:25 +0000 (Sun, 26 Nov 2006)
New Revision: 19909

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19909

Log:

Make this one double as fast


Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c	2006-11-26 16:06:11 UTC (rev 19908)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c	2006-11-26 21:49:25 UTC (rev 19909)
@@ -763,17 +763,29 @@
 char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t)
 {
 	struct tm *tm = gmtime(&t);
+	char *ts;
+	int r;
 
 	if (!tm) {
 		return NULL;
 	}
 
+	/* we now excatly how long this string will be */
+	ts = talloc_array(mem_ctx, char, 18);
+
 	/* formatted like: 20040408072012.0Z */
-	return talloc_asprintf(mem_ctx, 
-			       "%04u%02u%02u%02u%02u%02u.0Z",
-			       tm->tm_year+1900, tm->tm_mon+1,
-			       tm->tm_mday, tm->tm_hour, tm->tm_min,
-			       tm->tm_sec);
+	r = snprintf(ts, 18,
+			"%04u%02u%02u%02u%02u%02u.0Z",
+			tm->tm_year+1900, tm->tm_mon+1,
+			tm->tm_mday, tm->tm_hour, tm->tm_min,
+			tm->tm_sec);
+
+	if (r != 17) {
+		talloc_free(ts);
+		return NULL;
+	}
+
+	return ts;
 }
 
 



More information about the samba-cvs mailing list