X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fgbuf.h;h=0775f20cb3738bb976176a72af94918322261f9d;hb=2c9cf5b6e38800f6d79e5140f3b8565961374627;hp=59cc36a6ceed7df8ed8296c1177dff9d1dd4b1dc;hpb=02c4fffa40911fadcce3534c116be3e117d2b858;p=libucw.git diff --git a/lib/gbuf.h b/lib/gbuf.h index 59cc36a6..0775f20c 100644 --- a/lib/gbuf.h +++ b/lib/gbuf.h @@ -1,5 +1,5 @@ /* - * A simple growing buffer + * UCW Library -- A simple growing buffer * * (c) 2004, Robert Spalek * @@ -7,6 +7,9 @@ * * GBUF_TYPE data type of records stored in the buffer * GBUF_PREFIX(x) add a name prefix to all global symbols + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #include @@ -46,7 +49,7 @@ GBUF_PREFIX(realloc)(BUF_T *b, uns len) static inline void GBUF_PREFIX(grow)(BUF_T *b, uns len) { - if (len <= b->len) + if (likely(len <= b->len)) return; if (len < 2*b->len) // to ensure logarithmic cost len = 2*b->len; @@ -55,3 +58,4 @@ GBUF_PREFIX(grow)(BUF_T *b, uns len) #undef GBUF_TYPE #undef GBUF_PREFIX +#undef BUF_T