Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/C
diff options
context:
space:
mode:
Diffstat (limited to 'C')
-rwxr-xr-xC/Compress/Huffman/HuffmanEncode.h2
-rwxr-xr-xC/Compress/Lz/MatchFinder.c6
-rwxr-xr-xC/Compress/Lz/MatchFinderMt.c33
-rwxr-xr-xC/Compress/Lz/MatchFinderMt.h2
4 files changed, 17 insertions, 26 deletions
diff --git a/C/Compress/Huffman/HuffmanEncode.h b/C/Compress/Huffman/HuffmanEncode.h
index e59c86ad..c8acc283 100755
--- a/C/Compress/Huffman/HuffmanEncode.h
+++ b/C/Compress/Huffman/HuffmanEncode.h
@@ -5,8 +5,6 @@
#include "../../Types.h"
-#define HUFFMAN_TEMP_SIZE(num) (num * 2)
-
/*
Conditions:
num <= 1024 = 2 ^ NUM_BITS
diff --git a/C/Compress/Lz/MatchFinder.c b/C/Compress/Lz/MatchFinder.c
index 9c10c7ee..0f530fc1 100755
--- a/C/Compress/Lz/MatchFinder.c
+++ b/C/Compress/Lz/MatchFinder.c
@@ -503,7 +503,7 @@ UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (delta2 < p->cyclicBufferSize && *(cur - delta2) == *cur)
{
for (; maxLen != lenLimit; maxLen++)
- if (cur[(size_t)maxLen - delta2] != cur[maxLen])
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
break;
distances[0] = maxLen;
distances[1] = delta2 - 1;
@@ -550,7 +550,7 @@ UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (offset != 0)
{
for (; maxLen != lenLimit; maxLen++)
- if (cur[(size_t)maxLen - delta2] != cur[maxLen])
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
break;
distances[offset - 2] = maxLen;
if (maxLen == lenLimit)
@@ -597,7 +597,7 @@ UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (offset != 0)
{
for (; maxLen != lenLimit; maxLen++)
- if (cur[(size_t)maxLen - delta2] != cur[maxLen])
+ if (cur[(ptrdiff_t)maxLen - delta2] != cur[maxLen])
break;
distances[offset - 2] = maxLen;
if (maxLen == lenLimit)
diff --git a/C/Compress/Lz/MatchFinderMt.c b/C/Compress/Lz/MatchFinderMt.c
index fcb294cf..ea65a6e6 100755
--- a/C/Compress/Lz/MatchFinderMt.c
+++ b/C/Compress/Lz/MatchFinderMt.c
@@ -142,18 +142,11 @@ void MtSync_Init(CMtSync *p) { p->needStart = True; }
#define kMtMaxValForNormalize 0xFFFFFFFF
-/*
-Notes:
-instead of "size_t pos" we can use "UInt32 pos".
-But MSVC++ compilers have BUG:
-sometimes they use signed extending: (size_t)pos was compiled to "movsxd r10, edx"
-*/
-
#define DEF_GetHeads(name, v) \
-static void GetHeads ## name(const Byte *p, size_t pos, \
+static void GetHeads ## name(const Byte *p, UInt32 pos, \
UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads) { \
for (; numHeads != 0; numHeads--) { \
-const UInt32 value = (v); p++; *heads++ = (UInt32)pos - hash[value]; hash[value] = (UInt32)(pos++); } }
+const UInt32 value = (v); p++; *heads++ = pos - hash[value]; hash[value] = pos++; } }
DEF_GetHeads(2, (p[0] | ((UInt32)p[1] << 8)) & hashMask)
DEF_GetHeads(3, (g_CrcTable[p[0]] ^ p[1] ^ ((UInt32)p[2] << 8)) & hashMask)
@@ -586,7 +579,7 @@ UInt32 * MixMatches2(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
hash[hash2Value] = lzPos;
if (curMatch2 >= matchMinPos)
- if (cur[(size_t)curMatch2 - lzPos] == cur[0])
+ if (cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
{
*distances++ = 2;
*distances++ = lzPos - curMatch2 - 1;
@@ -609,10 +602,10 @@ UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
hash[kFix3HashSize + hash3Value] =
lzPos;
- if (curMatch2 >= matchMinPos && cur[(size_t)curMatch2 - lzPos] == cur[0])
+ if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
{
distances[1] = lzPos - curMatch2 - 1;
- if (cur[(size_t)curMatch2 - lzPos + 2] == cur[2])
+ if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])
{
distances[0] = 3;
return distances + 2;
@@ -620,7 +613,7 @@ UInt32 * MixMatches3(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
distances[0] = 2;
distances += 2;
}
- if (curMatch3 >= matchMinPos && cur[(size_t)curMatch3 - lzPos] == cur[0])
+ if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])
{
*distances++ = 3;
*distances++ = lzPos - curMatch3 - 1;
@@ -646,21 +639,21 @@ UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
hash[kFix4HashSize + hash4Value] =
lzPos;
- if (curMatch2 >= matchMinPos && cur[(size_t)curMatch2 - lzPos] == cur[0])
+ if (curMatch2 >= matchMinPos && cur[(ptrdiff_t)curMatch2 - lzPos] == cur[0])
{
distances[1] = lzPos - curMatch2 - 1;
- if (cur[(size_t)curMatch2 - lzPos + 2] == cur[2])
+ if (cur[(ptrdiff_t)curMatch2 - lzPos + 2] == cur[2])
{
- distances[0] = (cur[(size_t)curMatch2 - lzPos + 3] == cur[3]) ? 4 : 3;
+ distances[0] = (cur[(ptrdiff_t)curMatch2 - lzPos + 3] == cur[3]) ? 4 : 3;
return distances + 2;
}
distances[0] = 2;
distances += 2;
}
- if (curMatch3 >= matchMinPos && cur[(size_t)curMatch3 - lzPos] == cur[0])
+ if (curMatch3 >= matchMinPos && cur[(ptrdiff_t)curMatch3 - lzPos] == cur[0])
{
distances[1] = lzPos - curMatch3 - 1;
- if (cur[(size_t)curMatch3 - lzPos + 3] == cur[3])
+ if (cur[(ptrdiff_t)curMatch3 - lzPos + 3] == cur[3])
{
distances[0] = 4;
return distances + 2;
@@ -671,8 +664,8 @@ UInt32 *MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *distances)
if (curMatch4 >= matchMinPos)
if (
- cur[(size_t)curMatch4 - lzPos] == cur[0] &&
- cur[(size_t)curMatch4 - lzPos + 3] == cur[3]
+ cur[(ptrdiff_t)curMatch4 - lzPos] == cur[0] &&
+ cur[(ptrdiff_t)curMatch4 - lzPos + 3] == cur[3]
)
{
*distances++ = 4;
diff --git a/C/Compress/Lz/MatchFinderMt.h b/C/Compress/Lz/MatchFinderMt.h
index f9edc18f..e718a09e 100755
--- a/C/Compress/Lz/MatchFinderMt.h
+++ b/C/Compress/Lz/MatchFinderMt.h
@@ -38,7 +38,7 @@ typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distance
/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
#define kMtCacheLineDummy 128
-typedef void (*Mf_GetHeads)(const Byte *buffer, size_t pos,
+typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads);
typedef struct _CMatchFinderMt