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

Function SCompExplode

3rdParty/StormLib/src/SCompression.cpp:713–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711/*****************************************************************************/
712
713int STORMAPI SCompExplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
714{
715 int cbOutBuffer;
716
717 // Check for valid parameters
718 if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer)
719 {
720 SetLastError(ERROR_INVALID_PARAMETER);
721 return 0;
722 }
723
724 // If the input length is the same as output length, do nothing.
725 cbOutBuffer = *pcbOutBuffer;
726 if(cbInBuffer == cbOutBuffer)
727 {
728 // If the buffers are equal, don't copy anything.
729 if(pvInBuffer == pvOutBuffer)
730 return 1;
731
732 memcpy(pvOutBuffer, pvInBuffer, cbInBuffer);
733 return 1;
734 }
735
736 // Perform decompression
737 if(!Decompress_PKLIB(pvOutBuffer, &cbOutBuffer, pvInBuffer, cbInBuffer))
738 {
739 SetLastError(ERROR_FILE_CORRUPT);
740 return 0;
741 }
742
743 *pcbOutBuffer = cbOutBuffer;
744 return 1;
745}
746
747/*****************************************************************************/
748/* */

Callers 2

ReadMpqSectorsFunction · 0.85
ReadMpqFileSingleUnitFunction · 0.85

Calls 2

SetLastErrorFunction · 0.85
Decompress_PKLIBFunction · 0.85

Tested by

no test coverage detected