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

Function SCompImplode

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

Source from the content-addressed store, hash-verified

679/*****************************************************************************/
680
681int STORMAPI SCompImplode(void * pvOutBuffer, int * pcbOutBuffer, void * pvInBuffer, int cbInBuffer)
682{
683 int cbOutBuffer;
684
685 // Check for valid parameters
686 if(!pcbOutBuffer || *pcbOutBuffer < cbInBuffer || !pvOutBuffer || !pvInBuffer)
687 {
688 SetLastError(ERROR_INVALID_PARAMETER);
689 return 0;
690 }
691
692 // Perform the compression
693 cbOutBuffer = *pcbOutBuffer;
694 Compress_PKLIB(pvOutBuffer, &cbOutBuffer, pvInBuffer, cbInBuffer, NULL, 0);
695
696 // If the compression was unsuccessful, copy the data as-is
697 if(cbOutBuffer >= *pcbOutBuffer)
698 {
699 memcpy(pvOutBuffer, pvInBuffer, cbInBuffer);
700 cbOutBuffer = *pcbOutBuffer;
701 }
702
703 *pcbOutBuffer = cbOutBuffer;
704 return 1;
705}
706
707/*****************************************************************************/
708/* */

Callers

nothing calls this directly

Calls 2

SetLastErrorFunction · 0.85
Compress_PKLIBFunction · 0.85

Tested by

no test coverage detected