X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=lib%2Futils.c;fp=lib%2Futils.c;h=004523502cde8a2ace14829610c767e1e3c9b33b;hp=0000000000000000000000000000000000000000;hb=f0bbedf750f1530ec05bf2b8122479c924bbf2fe;hpb=0b26618eede5b215f03fc826ec504a8996dc8801 diff --git a/lib/utils.c b/lib/utils.c new file mode 100644 index 0000000..0045235 --- /dev/null +++ b/lib/utils.c @@ -0,0 +1,40 @@ +/* + ashd - A Sane HTTP Daemon + Copyright (C) 2008 Fredrik Tolf + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include + +#include + +void _sizebuf(struct buffer *buf, size_t wanted, size_t el) +{ + size_t n; + + n = buf->s; + if(n == 0) + n = 1; + while(n < wanted) + n <<= 1; + if(n <= buf->s) + return; + if(buf->b != NULL) + buf->b = srealloc(buf->b, n * el); + else + buf->b = smalloc(n * el); + buf->s = n; +} +