summaryrefslogtreecommitdiff
path: root/indra/llcommon/llcrc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llcrc.cpp')
-rw-r--r--indra/llcommon/llcrc.cpp116
1 files changed, 58 insertions, 58 deletions
diff --git a/indra/llcommon/llcrc.cpp b/indra/llcommon/llcrc.cpp
index 626bb1e564..34aa7b46e8 100644
--- a/indra/llcommon/llcrc.cpp
+++ b/indra/llcommon/llcrc.cpp
@@ -1,25 +1,25 @@
-/**
+/**
* @file llcrc.cpp
* @brief implementation of the crc class.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -142,77 +142,77 @@ LLCRC::LLCRC() : mCurrent(0xffffffff)
U32 LLCRC::getCRC() const
{
- return ~mCurrent;
+ return ~mCurrent;
}
void LLCRC::update(U8 next_byte)
{
- mCurrent = UPDC32(next_byte, mCurrent);
+ mCurrent = UPDC32(next_byte, mCurrent);
}
void LLCRC::update(const U8* buffer, size_t buffer_size)
{
- for (size_t i = 0; i < buffer_size; i++)
- {
- mCurrent = UPDC32(buffer[i], mCurrent);
- }
+ for (size_t i = 0; i < buffer_size; i++)
+ {
+ mCurrent = UPDC32(buffer[i], mCurrent);
+ }
}
void LLCRC::update(const std::string& filename)
{
- if (filename.empty())
- {
- LL_ERRS() << "No filename specified" << LL_ENDL;
- return;
- }
-
- FILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
-
- if (fp)
- {
- fseek(fp, 0, SEEK_END);
- long size = ftell(fp);
-
- fseek(fp, 0, SEEK_SET);
-
- if (size > 0)
- {
- U8* data = new U8[size];
- size_t nread;
-
- nread = fread(data, 1, size, fp);
- fclose(fp);
-
- if (nread < (size_t) size)
- {
- LL_WARNS() << "Short read on " << filename << LL_ENDL;
- }
-
- update(data, nread);
- delete[] data;
- }
- else
- {
- fclose(fp);
- }
- }
+ if (filename.empty())
+ {
+ LL_ERRS() << "No filename specified" << LL_ENDL;
+ return;
+ }
+
+ FILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
+
+ if (fp)
+ {
+ fseek(fp, 0, SEEK_END);
+ long size = ftell(fp);
+
+ fseek(fp, 0, SEEK_SET);
+
+ if (size > 0)
+ {
+ U8* data = new U8[size];
+ size_t nread;
+
+ nread = fread(data, 1, size, fp);
+ fclose(fp);
+
+ if (nread < (size_t) size)
+ {
+ LL_WARNS() << "Short read on " << filename << LL_ENDL;
+ }
+
+ update(data, nread);
+ delete[] data;
+ }
+ else
+ {
+ fclose(fp);
+ }
+ }
}
#ifdef _DEBUG
BOOL LLCRC::testHarness()
{
- const S32 TEST_BUFFER_SIZE = 16;
- const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; /* Flawfinder: ignore */
- LLCRC c1, c2;
- c1.update((U8*)TEST_BUFFER, TEST_BUFFER_SIZE - 1);
- char* rh = (char*)TEST_BUFFER;
- while(*rh != '\0')
- {
- c2.update(*rh);
- ++rh;
- }
- return(c1.getCRC() == c2.getCRC());
+ const S32 TEST_BUFFER_SIZE = 16;
+ const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; /* Flawfinder: ignore */
+ LLCRC c1, c2;
+ c1.update((U8*)TEST_BUFFER, TEST_BUFFER_SIZE - 1);
+ char* rh = (char*)TEST_BUFFER;
+ while(*rh != '\0')
+ {
+ c2.update(*rh);
+ ++rh;
+ }
+ return(c1.getCRC() == c2.getCRC());
}
#endif