diff options
author | Simo Sorce <idra@samba.org> | 2006-11-26 21:49:25 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:28:35 -0500 |
commit | 8ec78bcbbf38963f69a7f81afee438eb08d55b52 (patch) | |
tree | 8a167a3521b85c328adbc1173b7a70e853ecf39b /source4/lib/ldb/common | |
parent | 25579c6fe8a37b2726ab384bcb9b7e7a46f5e3ff (diff) | |
download | samba-8ec78bcbbf38963f69a7f81afee438eb08d55b52.tar.gz samba-8ec78bcbbf38963f69a7f81afee438eb08d55b52.tar.bz2 samba-8ec78bcbbf38963f69a7f81afee438eb08d55b52.zip |
r19909: Make this one double as fast
(This used to be commit 67b88e49b896f1d783619b8f96554adaeabe80df)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb_msg.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index e9ba66aff5..0f7a214023 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -763,17 +763,29 @@ void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element 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; } |