MCPcopy Create free account
hub / github.com/Kenix3/libultraship / SCompExplode

Function SCompExplode

extern/StormLib/src/SCompression.cpp:706–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

ReadMpqSectorsFunction · 0.85
ReadMpqFileSingleUnitFunction · 0.85

Calls 2

SetLastErrorFunction · 0.85
Decompress_PKLIBFunction · 0.85

Tested by

no test coverage detected