修正初始容量为0时,扩容会永远失败的BUG

This commit is contained in:
Stone 2016-06-20 08:26:17 +00:00
parent 7a7986c4e4
commit c3cad1019e
1 changed files with 3 additions and 2 deletions

View File

@ -355,8 +355,9 @@ bool MemoryStream::CheckRemain(uint count)
if(!CanResize) return Stream::CheckRemain(count);
// 原始容量成倍扩容
uint total = _Position + count;
uint size = _Capacity;
uint total = _Position + count;
uint size = _Capacity;
if(size < 0x10) size = 0x10;
while(size < total) size <<= 1;
// 申请新的空间,并复制数据