0

私のコードは何らかの理由でセグメンテーション違反を起こしています。関連するコードは次のとおりです。

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 で何が間違っていますか? それは必要ですか?ありがとう。

4

0 に答える 0