At Sat, 10 Aug 2013 02:05:40 +0800, Liu Yuan wrote: > > diff --git a/lib/util.c b/lib/util.c > index 2f877c4..82356d6 100644 > --- a/lib/util.c > +++ b/lib/util.c > @@ -46,9 +46,9 @@ try_to_free_t set_try_to_free_routine(try_to_free_t routine) > void *xmalloc(size_t size) > { > void *ret = malloc(size); > - if (!ret && !size) > + if (unlikely(!ret) && unlikely(!size)) > ret = malloc(1); > - if (!ret) { > + if (unlikely(!ret)) { > try_to_free_routine(size); > ret = malloc(size); > if (!ret && !size) > @@ -67,9 +67,9 @@ void *xzalloc(size_t size) > void *xrealloc(void *ptr, size_t size) > { > void *ret = realloc(ptr, size); > - if (!ret && !size) > + if (unlikely(!ret) && unlikely(!size)) > ret = realloc(ptr, 1); > - if (!ret) { > + if (unlikely(!ret)) { > try_to_free_routine(size); > ret = realloc(ptr, size); > if (!ret && !size) > @@ -83,9 +83,9 @@ void *xrealloc(void *ptr, size_t size) > void *xcalloc(size_t nmemb, size_t size) > { > void *ret = calloc(nmemb, size); > - if (!ret && (!nmemb || !size)) > + if (unlikely(!ret) && (!nmemb || !size)) Should be unlikey(!nmemb || !size) like xmalloc and xrealloc? Thanks Kazutaka |