大致思路就是这样:1、m_pSocketContextPool = new SocketContextEx[m_dwPreAllocSockets]; var m_dwPreAllocSockets: integer; m_pSocketContextPool :Array of SocketContextEx; begin setLength(m_pSocketContextPool, m_dwPreAllocSockets); for I:=0 to m_dwPreAllocSockets -1 do begin m_pSocketContextPool[I] := SocketContextEx.Create; end; end;
堆上分配了m_dwPreAllocSockets个连续的 SocketContextEx对象
你用个循环吧
m_dwPreAllocSockets: integer;
m_pSocketContextPool :Array of SocketContextEx;
begin
setLength(m_pSocketContextPool, m_dwPreAllocSockets);
for I:=0 to m_dwPreAllocSockets -1 do
begin
m_pSocketContextPool[I] := SocketContextEx.Create;
end;
end;