Commit | Line | Data |
---|---|---|
f0bbedf7 FT |
1 | /* |
2 | ashd - A Sane HTTP Daemon | |
3 | Copyright (C) 2008 Fredrik Tolf <fredrik@dolda2000.com> | |
4 | ||
5 | This program is free software: you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
7 | the Free Software Foundation, either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | #include <stdlib.h> | |
20 | ||
ddf99192 FT |
21 | #ifdef HAVE_CONFIG_H |
22 | #include <config.h> | |
23 | #endif | |
f0bbedf7 FT |
24 | #include <utils.h> |
25 | ||
26 | void _sizebuf(struct buffer *buf, size_t wanted, size_t el) | |
27 | { | |
28 | size_t n; | |
29 | ||
30 | n = buf->s; | |
31 | if(n == 0) | |
32 | n = 1; | |
33 | while(n < wanted) | |
34 | n <<= 1; | |
35 | if(n <= buf->s) | |
36 | return; | |
37 | if(buf->b != NULL) | |
38 | buf->b = srealloc(buf->b, n * el); | |
39 | else | |
40 | buf->b = smalloc(n * el); | |
41 | buf->s = n; | |
42 | } | |
43 |