3
void Netbuffer::check_space(unsigned extra) {
4
PROFILE("Netbuffer::check_space");
8
// When the first network buffer is allocated in HTTP mode, get
9
// twice as much. Most often that will be enough to fetch the whole
10
// client request, so that one realloc() will be spared.
11
if (extra == config.buffersize() &&
12
config.stype() == Servertype::t_http)
14
debugmsg (Mstr("Netbuffer: reserving ") + buf_alloced +
15
" bytes for network buffer\n");
17
buf_data = (char*)malloc(buf_alloced);
20
throw Error("Memory fault in Netbuffer::check_space");
21
} else if (buf_sz + extra > buf_alloced) {
22
debugmsg((Mstr("Netbuffer: reallocating net buffer from ") +
24
(Mstr(" to ") + (buf_alloced + extra)) + " bytes\n");
27
buf_data = (char*)realloc(buf_data, buf_alloced);
30
throw Error("Memory fault in Netbuffer::check_space");