diff options
Diffstat (limited to 'CPP/7zip/Compress/LzmaEncoder.cpp')
-rw-r--r-- | CPP/7zip/Compress/LzmaEncoder.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/CPP/7zip/Compress/LzmaEncoder.cpp b/CPP/7zip/Compress/LzmaEncoder.cpp index 484d0452..0a7e294d 100644 --- a/CPP/7zip/Compress/LzmaEncoder.cpp +++ b/CPP/7zip/Compress/LzmaEncoder.cpp @@ -12,29 +12,21 @@ namespace NCompress { namespace NLzma { -static void *SzBigAlloc(void *, size_t size) { return BigAlloc(size); } -static void SzBigFree(void *, void *address) { BigFree(address); } -static ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree }; - -static void *SzAlloc(void *, size_t size) { return MyAlloc(size); } -static void SzFree(void *, void *address) { MyFree(address); } -static ISzAlloc g_Alloc = { SzAlloc, SzFree }; - CEncoder::CEncoder() { - _encoder = 0; + _encoder = NULL; _encoder = LzmaEnc_Create(&g_Alloc); - if (_encoder == 0) + if (!_encoder) throw 1; } CEncoder::~CEncoder() { - if (_encoder != 0) + if (_encoder) LzmaEnc_Destroy(_encoder, &g_Alloc, &g_BigAlloc); } -inline wchar_t GetUpperChar(wchar_t c) +static inline wchar_t GetUpperChar(wchar_t c) { if (c >= 'a' && c <= 'z') c -= 0x20; @@ -51,22 +43,21 @@ static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes) int numHashBytesLoc = (int)(*s++ - L'0'); if (numHashBytesLoc < 4 || numHashBytesLoc > 4) return 0; - if (*s++ != 0) + if (*s != 0) return 0; *btMode = 0; *numHashBytes = numHashBytesLoc; return 1; } + if (c != L'B') return 0; - if (GetUpperChar(*s++) != L'T') return 0; int numHashBytesLoc = (int)(*s++ - L'0'); if (numHashBytesLoc < 2 || numHashBytesLoc > 4) return 0; - c = GetUpperChar(*s++); - if (c != L'\0') + if (*s != 0) return 0; *btMode = 1; *numHashBytes = numHashBytesLoc; |