mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
Fix memory issues in resource manager
This commit is contained in:
parent
c91a85a353
commit
3f42df45fd
1 changed files with 7 additions and 6 deletions
|
@ -147,8 +147,8 @@ void Resource::Init(const char *filename)
|
||||||
int nNameLength = strnlen(tdict[i].name, 8);
|
int nNameLength = strnlen(tdict[i].name, 8);
|
||||||
dict[i].type = (char*)Alloc(nTypeLength+1);
|
dict[i].type = (char*)Alloc(nTypeLength+1);
|
||||||
dict[i].name = (char*)Alloc(nNameLength+1);
|
dict[i].name = (char*)Alloc(nNameLength+1);
|
||||||
strncpy(dict[i].type, tdict[i].type, 3);
|
strncpy(dict[i].type, tdict[i].type, min(3, nTypeLength));
|
||||||
strncpy(dict[i].name, tdict[i].name, 8);
|
strncpy(dict[i].name, tdict[i].name, min(8, nNameLength));
|
||||||
dict[i].type[nTypeLength] = 0;
|
dict[i].type[nTypeLength] = 0;
|
||||||
dict[i].name[nNameLength] = 0;
|
dict[i].name[nNameLength] = 0;
|
||||||
dict[i].id = B_LITTLE32(tdict[i].id);
|
dict[i].id = B_LITTLE32(tdict[i].id);
|
||||||
|
@ -234,7 +234,7 @@ void Resource::Flush(CACHENODE *h)
|
||||||
#ifdef USE_QHEAP
|
#ifdef USE_QHEAP
|
||||||
heap->Free(h->ptr);
|
heap->Free(h->ptr);
|
||||||
#else
|
#else
|
||||||
delete h->ptr;
|
delete[] (char*)h->ptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
h->ptr = NULL;
|
h->ptr = NULL;
|
||||||
|
@ -489,7 +489,7 @@ void *Resource::Alloc(int nSize)
|
||||||
{
|
{
|
||||||
dassert(node->lockCount == 0);
|
dassert(node->lockCount == 0);
|
||||||
dassert(node->ptr != NULL);
|
dassert(node->ptr != NULL);
|
||||||
delete node->ptr;
|
delete[] (char*)node->ptr;
|
||||||
node->ptr = NULL;
|
node->ptr = NULL;
|
||||||
RemoveMRU(node);
|
RemoveMRU(node);
|
||||||
p = new char[nSize];
|
p = new char[nSize];
|
||||||
|
@ -509,7 +509,7 @@ void Resource::Free(void *p)
|
||||||
heap->Free(p);
|
heap->Free(p);
|
||||||
#else
|
#else
|
||||||
dassert(p != NULL);
|
dassert(p != NULL);
|
||||||
delete p;
|
delete[] (char*)p;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +807,8 @@ void Resource::RemoveNode(DICTNODE* pNode)
|
||||||
pNode->type = NULL;
|
pNode->type = NULL;
|
||||||
}
|
}
|
||||||
*pNode = dict[--count];
|
*pNode = dict[--count];
|
||||||
if (pNode->ptr)
|
Bmemset(&dict[count], 0, sizeof(DICTNODE));
|
||||||
|
if (pNode->ptr && !pNode->lockCount)
|
||||||
{
|
{
|
||||||
pNode->prev->next = pNode;
|
pNode->prev->next = pNode;
|
||||||
pNode->next->prev = pNode;
|
pNode->next->prev = pNode;
|
||||||
|
|
Loading…
Reference in a new issue