Saner allocation policy for DataPacks.
This commit is contained in:
parent
55dee2d847
commit
7f97e67931
@ -33,7 +33,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "CDataPack.h"
|
#include "CDataPack.h"
|
||||||
|
|
||||||
#define DATAPACK_INITIAL_SIZE 512
|
#define DATAPACK_INITIAL_SIZE 64
|
||||||
|
|
||||||
CDataPack::CDataPack()
|
CDataPack::CDataPack()
|
||||||
{
|
{
|
||||||
@ -64,9 +64,10 @@ void CDataPack::CheckSize(size_t typesize)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
m_capacity *= 2;
|
m_capacity *= 2;
|
||||||
|
} while (pos + typesize > m_capacity);
|
||||||
|
|
||||||
m_pBase = (char *)realloc(m_pBase, m_capacity);
|
m_pBase = (char *)realloc(m_pBase, m_capacity);
|
||||||
m_curptr = m_pBase + pos;
|
m_curptr = m_pBase + pos;
|
||||||
} while (m_curptr - m_pBase + typesize > m_capacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDataPack::ResetSize()
|
void CDataPack::ResetSize()
|
||||||
|
Loading…
Reference in New Issue
Block a user