MCPcopy Create free account
hub / github.com/diasurgical/devilution / FreeArchiveHandle

Function FreeArchiveHandle

3rdParty/StormLib/src/SBaseCommon.cpp:1582–1621  ·  view source on GitHub ↗

Frees the MPQ archive

Source from the content-addressed store, hash-verified

1580
1581// Frees the MPQ archive
1582void FreeArchiveHandle(TMPQArchive *& ha)
1583{
1584 if(ha != NULL)
1585 {
1586 // First of all, free the patch archive, if any
1587 if(ha->haPatch != NULL)
1588 FreeArchiveHandle(ha->haPatch);
1589
1590 // Free the patch prefix, if any
1591 if(ha->pPatchPrefix != NULL)
1592 STORM_FREE(ha->pPatchPrefix);
1593
1594 // Close the file stream
1595 FileStream_Close(ha->pStream);
1596 ha->pStream = NULL;
1597
1598 // Free the file names from the file table
1599 if(ha->pFileTable != NULL)
1600 {
1601 for(DWORD i = 0; i < ha->dwFileTableSize; i++)
1602 {
1603 if(ha->pFileTable[i].szFileName != NULL)
1604 STORM_FREE(ha->pFileTable[i].szFileName);
1605 ha->pFileTable[i].szFileName = NULL;
1606 }
1607
1608 // Then free all buffers allocated in the archive structure
1609 STORM_FREE(ha->pFileTable);
1610 }
1611
1612 if(ha->pHashTable != NULL)
1613 STORM_FREE(ha->pHashTable);
1614#ifdef FULL
1615 if(ha->pHetTable != NULL)
1616 FreeHetTable(ha->pHetTable);
1617#endif
1618 STORM_FREE(ha);
1619 ha = NULL;
1620 }
1621}
1622
1623bool IsInternalMpqFileName(const char * szFileName)
1624{

Callers 2

SFileOpenArchiveFunction · 0.85
SFileCloseArchiveFunction · 0.85

Calls 2

FileStream_CloseFunction · 0.85
FreeHetTableFunction · 0.85

Tested by

no test coverage detected