From 14e22779625de673569c7b950ecc2753fb915b31 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Tue, 27 Apr 2010 06:56:47 +0000 Subject: Since some people disapprove of white space cleanups mixed in regular commits while others dislike them being extra commits, let's clean them up once and for all for the existing code. If it's ugly, let it only be ugly once :-) Signed-off-by: Stefan Reinauer Acked-by: Stefan Reinauer git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5507 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- util/cbfstool/lzma/minilzma.cc | 58 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'util/cbfstool/lzma/minilzma.cc') diff --git a/util/cbfstool/lzma/minilzma.cc b/util/cbfstool/lzma/minilzma.cc index 5437b59946..2625cb5083 100644 --- a/util/cbfstool/lzma/minilzma.cc +++ b/util/cbfstool/lzma/minilzma.cc @@ -89,7 +89,7 @@ static UInt32 SelectDictionarySizeFor(unsigned datasize) if(datasize <= 512) return 512; if(datasize <= 1024) return 1024; if(datasize <= 4096) return 4096; - if(datasize <= 16384) return 32768; + if(datasize <= 16384) return 32768; if(datasize <= 65536) return 528288; if(datasize <= 528288) return 1048576*4; if(datasize <= 786432) reutrn 1048576*16; @@ -105,12 +105,12 @@ class CInStreamRam: public ISequentialInStream, public CMyUnknownImp size_t Pos; public: MY_UNKNOWN_IMP - + CInStreamRam(const std::vector& buf) : input(buf), Pos(0) { } virtual ~CInStreamRam() {} - + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); }; @@ -118,12 +118,12 @@ STDMETHODIMP CInStreamRam::Read(void *data, UInt32 size, UInt32 *processedSize) { UInt32 remain = input.size() - Pos; if (size > remain) size = remain; - + std::memcpy(data, &input[Pos], size); Pos += size; - + if(processedSize != NULL) *processedSize = size; - + return S_OK; } @@ -133,27 +133,27 @@ class COutStreamRam: public ISequentialOutStream, public CMyUnknownImp size_t Pos; public: MY_UNKNOWN_IMP - + COutStreamRam(): result(), Pos(0) { } virtual ~COutStreamRam() { } - + void Reserve(unsigned n) { result.reserve(n); } const std::vector& Get() const { return result; } - + HRESULT WriteByte(Byte b) { if(Pos >= result.size()) result.resize(Pos+1); result[Pos++] = b; return S_OK; } - + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); }; STDMETHODIMP COutStreamRam::Write(const void *data, UInt32 size, UInt32 *processedSize) { if(Pos+size > result.size()) result.resize(Pos+size); - + std::memcpy(&result[Pos], data, size); if(processedSize != NULL) *processedSize = size; Pos += size; @@ -163,15 +163,15 @@ STDMETHODIMP COutStreamRam::Write(const void *data, UInt32 size, UInt32 *process const std::vector LZMACompress(const std::vector& buf) { if(buf.empty()) return buf; - + const UInt32 dictionarysize = SelectDictionarySizeFor(buf.size()); - + NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder; CMyComPtr encoder = encoderSpec; - const PROPID propIDs[] = + const PROPID propIDs[] = { NCoderPropID::kAlgorithm, - NCoderPropID::kDictionarySize, + NCoderPropID::kDictionarySize, NCoderPropID::kNumFastBytes, }; const unsigned kNumProps = sizeof(propIDs) / sizeof(propIDs[0]); @@ -185,16 +185,16 @@ const std::vector LZMACompress(const std::vector& Error: return std::vector (); } - + COutStreamRam *const outStreamSpec = new COutStreamRam; CMyComPtr outStream = outStreamSpec; CInStreamRam *const inStreamSpec = new CInStreamRam(buf); CMyComPtr inStream = inStreamSpec; - + outStreamSpec->Reserve(buf.size()); if (encoderSpec->WriteCoderProperties(outStream) != S_OK) goto Error; - + for (unsigned i = 0; i < 8; i++) { UInt64 t = (UInt64)buf.size(); @@ -203,7 +203,7 @@ const std::vector LZMACompress(const std::vector& HRESULT lzmaResult = encoder->Code(inStream, outStream, 0, 0, 0); if (lzmaResult != S_OK) goto Error; - + return outStreamSpec->Get(); } @@ -216,22 +216,22 @@ const std::vector LZMADeCompress (const std::vector& buf) { if(buf.size() <= 5+8) return std::vector (); - + uint_least64_t out_sizemax = R64(&buf[5]); - + std::vector result(out_sizemax); - + CLzmaDecoderState state; LzmaDecodeProperties(&state.Properties, &buf[0], LZMA_PROPERTIES_SIZE); state.Probs = new CProb[LzmaGetNumProbs(&state.Properties)]; - + SizeT in_done; SizeT out_done; LzmaDecode(&state, &buf[13], buf.size()-13, &in_done, &result[0], result.size(), &out_done); - + delete[] state.Probs; - + result.resize(out_done); return result; } @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) char *s; FILE *f, *infile, *outfile; int c; - + if (argc != 4) { std::fprintf(stderr, "'lzma e file1 file2' encodes file1 into file2.\n" "'lzma d file2 file1' decodes file2 into file1.\n"); @@ -270,9 +270,9 @@ int main(int argc, char *argv[]) fread(Buf,si, 1, infile); std::vector result; - if (toupper(*argv[1]) == 'E') + if (toupper(*argv[1]) == 'E') result = LZMACompress(std::vector(Buf,Buf+si)); - else + else result = LZMADeCompress(std::vector(Buf,Buf+si)); fwrite(&result[0], result.size(), 1, outfile); @@ -289,7 +289,7 @@ extern "C" { * @param in a pointer to the buffer * @param in_len the length in bytes * @param out a pointer to a buffer of at least size in_len - * @param out_len a pointer to the compressed length of in + * @param out_len a pointer to the compressed length of in */ void do_lzma_compress(char *in, int in_len, char *out, int *out_len) { -- cgit v1.2.3