07/01/31 01:10:11 94hlWcQw
>>202
フラグ管理より双方向リストでつないどくのが良いと思うけどな。
struct PoolNode
{
struct PoolNode* pn_next;
struct PoolNode* pn_prev;
char pn_padding[8]; //必要なら
char pn_buf[PN_BUFSIZE];
};
static PoolNode nodes[NODENUM];
// 未使用ノードは、こっちにつなぐ
static PoolNode* free_first = &nodes[0];
// 使用中ノードは、こっちにつなぐ
static PoolNode* inuse_first = 0;
現実には、俺なら自前で書かずに STLport の node allocator にお任せして、
STLコンテナ使っちゃうか、boost::pool だけと。