Skip to content

Commit

Permalink
update lz4 v1.10.0
Browse files Browse the repository at this point in the history
clear code
  • Loading branch information
irov committed Oct 4, 2024
1 parent 872971d commit 01247be
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 40 deletions.
2 changes: 1 addition & 1 deletion cmake/Downloads/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GIT_CLONE(stdex https://github.com/irov/stdex.git)
GIT_CLONE(libmovie https://github.com/irov/libmovie.git)
GIT_CLONE(json https://github.com/irov/json.git)
GIT_CLONE(utf8 https://github.com/nemtrif/utfcpp.git "v4.0.5")
GIT_CLONE(lz4 https://github.com/lz4/lz4.git "v1.9.4")
GIT_CLONE(lz4 https://github.com/lz4/lz4.git "v1.10.0")
GIT_CLONE(poly2tri https://github.com/jhasse/poly2tri.git)
GIT_CLONE(tinyini https://github.com/irov/tinyini.git)
GIT_CLONE(libfe https://github.com/frankinshtein/font-effects-lib.git)
Expand Down
4 changes: 2 additions & 2 deletions src/Environment/Windows/Win32Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace Mengine
, (DWORD)_id
, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US )
, (LPSTR)_message
, _capacity
, (DWORD)_capacity
, NULL ) == 0 )
{
DWORD lastError = ::GetLastError();
Expand All @@ -111,7 +111,7 @@ namespace Mengine
, (DWORD)_id
, MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US )
, (LPWSTR)_message
, _capacity
, (DWORD)_capacity
, NULL ) == 0 )
{
DWORD lastError = ::GetLastError();
Expand Down
10 changes: 5 additions & 5 deletions src/Kernel/SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace Mengine
uint8_t buffer[64];
};
//////////////////////////////////////////////////////////////////////////
static uint32_t SHA1_rotl32( uint32_t var, uint32_t hops )
MENGINE_CONSTEXPR uint32_t SHA1_rotl32( uint32_t var, uint32_t hops )
{
return (var << hops) | (var >> (32 - hops));
}
//////////////////////////////////////////////////////////////////////////
static void SHA1_Transform( uint32_t state[5], const uint8_t buffer[64] )
MENGINE_CONSTEXPR void SHA1_Transform( uint32_t state[5], const uint8_t buffer[64] )
{
typedef union
{
Expand Down Expand Up @@ -79,7 +79,7 @@ namespace Mengine
state[4] += e;
}
//////////////////////////////////////////////////////////////////////////
static void SHA1_Init( SHA1_CTX * context )
MENGINE_INLINE void SHA1_Init( SHA1_CTX * context )
{
context->state[0] = 0x67452301;
context->state[1] = 0xEFCDAB89;
Expand All @@ -90,7 +90,7 @@ namespace Mengine
context->count[1] = 0;
}
//////////////////////////////////////////////////////////////////////////
static void SHA1_Update( SHA1_CTX * context, const uint8_t * data, size_t len )
MENGINE_INLINE void SHA1_Update( SHA1_CTX * context, const uint8_t * data, size_t len )
{
size_t j = (context->count[0] >> 3) & 63;

Expand Down Expand Up @@ -124,7 +124,7 @@ namespace Mengine
StdString::memcpy( &context->buffer[j], &data[i], (len - i) * sizeof( uint8_t ) );
}
//////////////////////////////////////////////////////////////////////////
static void SHA1_Final( SHA1_CTX * context, uint8_t * const digest, size_t _size )
MENGINE_INLINE void SHA1_Final( SHA1_CTX * context, uint8_t * const digest, size_t _size )
{
uint8_t finalcount[8];

Expand Down
2 changes: 2 additions & 0 deletions src/Platforms/Win32Platform/Win32PlatformService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ namespace Mengine

uint32_t deviceSeed = Helper::generateRandomDeviceSeed();

MENGINE_UNUSED( deviceSeed );

LOGGER_INFO_PROTECTED( "platform", "device seed: %u"
, deviceSeed
);
Expand Down
3 changes: 2 additions & 1 deletion src/Plugins/ImageCodecPlugin/ImageDecoderHTF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ namespace Mengine
}

return PF_UNKNOWN;
};
}
///////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////////
ImageDecoderHTF::ImageDecoderHTF()
Expand Down
5 changes: 3 additions & 2 deletions src/Tools/AstralaxCompiler/AstralaxCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL

int lz_size = ::LZ4_compressBound( f_size );

std::vector<char> lz4_buffer( lz_size );
char * lz4_memory = &lz4_buffer[0];
char * lz4_memory = new char[lz_size];

char * dst_buffer = (char *)lz4_memory;
const char * src_buffer = (const char *)mf_buffer;
Expand All @@ -362,6 +361,8 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
fwrite( dst_buffer, compressSize, 1, fz );
fclose( fz );

delete [] lz4_memory;

_wremove( outCanonicalize );
}

Expand Down
5 changes: 3 additions & 2 deletions src/Tools/DazzleCompiler/DazzleCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ static bool writeCompress( const std::wstring & _filepath, const std::vector<uin

int lz_size = ::LZ4_compressBound( buffer_size );

std::vector<char> lz4_buffer( lz_size );
char * lz4_memory = &lz4_buffer[0];
char * lz4_memory = new char[lz_size];

char * dst_buffer = (char *)lz4_memory;
const char * src_buffer = (const char *)&_buffer[0];
Expand All @@ -125,6 +124,8 @@ static bool writeCompress( const std::wstring & _filepath, const std::vector<uin
::fwrite( dst_buffer, compressSize, 1, fz );
::fclose( fz );

delete [] lz4_memory;

return true;
}
//////////////////////////////////////////////////////////////////////////
Expand Down
18 changes: 9 additions & 9 deletions src/Tools/ExtractorDXT1/ExtractorDXT1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
{
message_error( "not found 'in' param" );

return 1;
return EXIT_FAILURE;
}

if( out.empty() == true )
{
message_error( "not found 'out' param" );

return 1;
return EXIT_FAILURE;
}

WCHAR inCanonicalizeQuote[MAX_PATH];
WCHAR inCanonicalizeQuote[MAX_PATH] = {L'\0'};
::ForcePathQuoteSpaces( inCanonicalizeQuote, in.c_str() );
::PathUnquoteSpaces( inCanonicalizeQuote );

Expand All @@ -139,7 +139,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, in.c_str()
);

return 1;
return EXIT_FAILURE;
}

DDS_HEADER header;
Expand All @@ -161,21 +161,21 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, in.c_str()
);

return 1;
return EXIT_FAILURE;
}

if( (header.ddspf.dwFlags & DDPF_FOURCC) == 0 )
{
message_error( "ExtractDXT1 dds file no compress" );

return false;
return EXIT_FAILURE;
}

if( header.ddspf.dwFourCC != FOURCC( 'D', 'X', 'T', '1' ) )
{
message_error( "ExtractDXT1 dds file no DXT1" );

return false;
return EXIT_FAILURE;
}

uint32_t w = (header.dwWidth + 3) / 4;
Expand All @@ -187,7 +187,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
fread( dxt1_byte, 1, size, file_in );
fclose( file_in );

WCHAR outCanonicalizeQuote[MAX_PATH];
WCHAR outCanonicalizeQuote[MAX_PATH] = {'\0'};
::ForcePathQuoteSpaces( outCanonicalizeQuote, out.c_str() );
::PathUnquoteSpaces( outCanonicalizeQuote );

Expand All @@ -198,5 +198,5 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL

delete[] dxt1_byte;

return 0;
return EXIT_SUCCESS;
}
16 changes: 7 additions & 9 deletions src/Tools/ExtractorETC1/ExtractorETC1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,16 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL

if( in.empty() == true )
{
message_error( "not found 'in' param"
);
message_error( "not found 'in' param" );

return 1;
return EXIT_FAILURE;
}

if( out.empty() == true )
{
message_error( "not found 'out' param"
);
message_error( "not found 'out' param" );

return 1;
return EXIT_FAILURE;
}

WCHAR inCanonicalizeQuote[MAX_PATH];
Expand All @@ -112,7 +110,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, inCanonicalizeQuote
);

return 1;
return EXIT_FAILURE;
}

PVRTextureHeader header;
Expand Down Expand Up @@ -141,13 +139,13 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, inCanonicalizeQuote
);

return 1;
return EXIT_FAILURE;
}

fwrite( etc1_byte, 1, size, file_out );
fclose( file_out );

delete[] etc1_byte;

return 0;
return EXIT_SUCCESS;
}
14 changes: 7 additions & 7 deletions src/Tools/ImagePolygonize/ImagePolygonize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
{
message_error( "not found 'texturepacker' param" );

return 0;
return EXIT_FAILURE;
}

if( in_path.empty() == true )
{
message_error( "not found 'image' param" );

return 0;
return EXIT_FAILURE;
}

std::wstring system_cmd;
Expand Down Expand Up @@ -108,7 +108,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, lpCommandLine
);

return 0;
return EXIT_FAILURE;
}

CloseHandle( lpProcessInformation.hThread );
Expand All @@ -127,7 +127,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, exit_code
);

return 0;
return EXIT_FAILURE;
}

FILE * f = _wfopen( outCanonicalize, L"rb" );
Expand All @@ -138,7 +138,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, outCanonicalize
);

return 0;
return EXIT_FAILURE;
}

fseek( f, 0, SEEK_END );
Expand Down Expand Up @@ -289,7 +289,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
, err
);

return 0;
return EXIT_FAILURE;
}

fprintf_s( f_result, "%u\n", vertex_count );
Expand Down Expand Up @@ -324,5 +324,5 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL

fclose( f_result );

return 0;
return EXIT_SUCCESS;
}
4 changes: 2 additions & 2 deletions src/Tools/RegistrationExport/RegistrationExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int WINAPI WinMain( HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz

/* Register the window class, and if it fails quit the program */
if( !RegisterClassEx( &wincl ) )
return 0;
return EXIT_FAILURE;

/* The class is registered, let's create the program*/
hwnd = CreateWindowEx(
Expand Down Expand Up @@ -80,7 +80,7 @@ int WINAPI WinMain( HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
}

/* The program return-value is 0 - The value that PostQuitMessage() gave */
return 0;
return EXIT_SUCCESS;
}

#define ID_BTN_Game 1
Expand Down

0 comments on commit 01247be

Please sign in to comment.