GSDX: Fixed the allocation checks in the previous couple of revs.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5832 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
sudonim1@gmail.com 2014-01-25 19:14:28 +00:00
parent ab1f4f99af
commit d6457e9983
2 changed files with 12 additions and 12 deletions

View File

@ -123,15 +123,17 @@ protected:
int maxcount = std::max<int>(m_maxcount * 3 / 2, 10000);
Vertex* vertices = (Vertex*)_aligned_malloc(sizeof(Vertex) * maxcount, 32);
if (!vertices)
{
printf("GSdx: failed to allocate %d bytes for verticles.\n", sizeof(Vertex) * maxcount);
throw GSDXError();
}
if (m_vertices != NULL && vertices != NULL)
{
memcpy(vertices, m_vertices, sizeof(Vertex) * m_maxcount);
_aligned_free(m_vertices);
}
else // very bad!
{
printf("GSdx: failed to allocate %d bytes for verticles.\n", sizeof(Vertex) * maxcount);
}
m_vertices = vertices;
m_maxcount = maxcount - 100;

View File

@ -2300,16 +2300,18 @@ void GSState::GrowVertexBuffer()
GSVertex* vertex = (GSVertex*)_aligned_malloc(sizeof(GSVertex) * maxcount, 32);
uint32* index = (uint32*)_aligned_malloc(sizeof(uint32) * maxcount * 3, 32); // worst case is slightly less than vertex number * 3
if (!vertex || !index)
{
printf("GSdx: failed to allocate %d bytes for verticles and %d for indices.\n", sizeof(GSVertex) * maxcount, sizeof(uint32) * maxcount * 3);
throw GSDXError();
}
if (m_vertex.buff != NULL && vertex != NULL)
{
memcpy(vertex, m_vertex.buff, sizeof(GSVertex) * m_vertex.tail);
_aligned_free(m_vertex.buff);
}
else // very bad!
{
printf("GSdx: failed to allocate %d bytes for verticles.\n", sizeof(GSVertex) * maxcount);
}
if (m_index.buff != NULL && index != NULL)
{
@ -2317,10 +2319,6 @@ void GSState::GrowVertexBuffer()
_aligned_free(m_index.buff);
}
else // very bad!
{
printf("GSdx: failed to allocate %d bytes for indices.\n", sizeof(uint32) * maxcount * 3);
}
m_vertex.buff = vertex;
m_vertex.maxcount = maxcount - 3; // -3 to have some space at the end of the buffer before DrawingKick can grow it