mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Fix a compatibility issue with the "reserved" parameter.
This commit is contained in:
parent
8c591bf065
commit
aa4e60ae27
@ -41,25 +41,14 @@ static cell AMX_NATIVE_CALL ArrayCreate(AMX* amx, cell* params)
|
|||||||
{
|
{
|
||||||
if (VectorHolder[i]==NULL)
|
if (VectorHolder[i]==NULL)
|
||||||
{
|
{
|
||||||
VectorHolder[i] = new CellArray(cellsize);
|
VectorHolder[i] = new CellArray(cellsize, reserved);
|
||||||
|
|
||||||
if (reserved > 0)
|
|
||||||
{
|
|
||||||
VectorHolder[i]->resize(reserved);
|
|
||||||
}
|
|
||||||
|
|
||||||
return i + 1;
|
return i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// None are NULL, create a new vector
|
// None are NULL, create a new vector
|
||||||
CellArray* NewVector = new CellArray(cellsize);
|
CellArray* NewVector = new CellArray(cellsize, reserved);
|
||||||
|
|
||||||
if (reserved > 0)
|
|
||||||
{
|
|
||||||
NewVector->resize(reserved);
|
|
||||||
}
|
|
||||||
|
|
||||||
VectorHolder.append(NewVector);
|
VectorHolder.append(NewVector);
|
||||||
|
|
||||||
return VectorHolder.length();
|
return VectorHolder.length();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
class CellArray
|
class CellArray
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CellArray(size_t blocksize) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_Size(0)
|
CellArray(size_t blocksize, size_t basesize = 0) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_BaseSize(basesize > 0 ? basesize : 8), m_Size(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ private:
|
|||||||
/* Set a base allocation size of 8 items */
|
/* Set a base allocation size of 8 items */
|
||||||
if (!m_AllocSize)
|
if (!m_AllocSize)
|
||||||
{
|
{
|
||||||
m_AllocSize = 8;
|
m_AllocSize = m_BaseSize;
|
||||||
}
|
}
|
||||||
/* If it's not enough, keep doubling */
|
/* If it's not enough, keep doubling */
|
||||||
while (m_Size + count > m_AllocSize)
|
while (m_Size + count > m_AllocSize)
|
||||||
@ -181,6 +181,7 @@ private:
|
|||||||
cell *m_Data;
|
cell *m_Data;
|
||||||
size_t m_BlockSize;
|
size_t m_BlockSize;
|
||||||
size_t m_AllocSize;
|
size_t m_AllocSize;
|
||||||
|
size_t m_BaseSize;
|
||||||
size_t m_Size;
|
size_t m_Size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user