提升singleton_pool :: malloc返回多少内存?

时间:2013-04-16 06:10:01

标签: c++ boost

由于某些原因,我的代码是segfaulting。 这是相关的代码。

typedef boost::singleton_pool<httpHandler,sizeof(httphandler)> httpHandlerpool;
typedef boost::singleton_pool<Conn ,sizeof(Conn)> connpool;


void *httphandler::operator new(size_t size)
{
     return httpHandlerpool::malloc();
}

//there is a corresponding delete as well.    

void *Conn::operator new(size_t size)
{
     return connpool::malloc();
}

//there is a corresponding delete as well.



Conn* httpHandler::getFreeConn()
{
    Conn *c=0;
    c = new Conn(); // 
    memset(c,0,sizeof *c); // This is where looks like some issue is there.
    return c
}

在我执行新Conn的代码中,将分配多少内存?它是'sizeof struct Conn`吗? memset我做错了什么?有必要吗? 感谢。

0 个答案:

没有答案