r25207: remove one nesting level and use unlikely()
authorStefan Metzmacher <metze@samba.org>
Tue, 18 Sep 2007 11:52:35 +0000 (11:52 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:06:53 +0000 (15:06 -0500)
metze
(This used to be commit c2931540bc6e2d7665ef46a123f1c0618c3b55b7)

source4/lib/talloc/talloc.c

index d4c845fa88da1aa46621aa8e72e2a5125e3bbcd9..92970426e80680925ff79dd9b904bdc68734151e 100644 (file)
@@ -1186,18 +1186,18 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
        va_copy(ap2, ap);
        len = vsnprintf(&c, 1, fmt, ap2);
        va_end(ap2);
-       if (len < 0) {
+       if (unlikely(len < 0)) {
                return NULL;
        }
 
        ret = (char *)__talloc(t, len+1);
-       if (ret) {
-               va_copy(ap2, ap);
-               vsnprintf(ret, len+1, fmt, ap2);
-               va_end(ap2);
-               _talloc_set_name_const(ret, ret);
-       }
+       if (unlikely(!ret)) return NULL;
+
+       va_copy(ap2, ap);
+       vsnprintf(ret, len+1, fmt, ap2);
+       va_end(ap2);
 
+       _talloc_set_name_const(ret, ret);
        return ret;
 }