diff options
author | Loren Shih <seraph@lindenlab.com> | 2010-10-04 11:21:18 -0400 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2010-10-04 11:21:18 -0400 |
commit | d65e512fa3a0e7bc7f1c269d2c8d2e1c38c4e970 (patch) | |
tree | 324168722ec39359f4753aa4acf6ca65c8b72ab3 /indra/newview/llvocache.cpp | |
parent | d3e71fdc2c35ab75ebdac573698bbb86bbd0d98f (diff) | |
parent | d3a9d6a6cef6630995c652b4cc04c8807dbe6d4e (diff) |
Automated merge up from viewer-development
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rw-r--r-- | indra/newview/llvocache.cpp | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 442b3c3e33..1cb3962daa 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -45,25 +45,27 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) //--------------------------------------------------------------------------- LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp) + : + mLocalID(local_id), + mCRC(crc), + mHitCount(0), + mDupeCount(0), + mCRCChangeCount(0) { - mLocalID = local_id; - mCRC = crc; - mHitCount = 0; - mDupeCount = 0; - mCRCChangeCount = 0; mBuffer = new U8[dp.getBufferSize()]; mDP.assignBuffer(mBuffer, dp.getBufferSize()); mDP = dp; } LLVOCacheEntry::LLVOCacheEntry() + : + mLocalID(0), + mCRC(0), + mHitCount(0), + mDupeCount(0), + mCRCChangeCount(0), + mBuffer(NULL) { - mLocalID = 0; - mCRC = 0; - mHitCount = 0; - mDupeCount = 0; - mCRCChangeCount = 0; - mBuffer = NULL; mDP.assignBuffer(mBuffer, 0); } @@ -74,7 +76,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) success = check_read(apr_file, &mLocalID, sizeof(U32)); if(success) -{ + { success = check_read(apr_file, &mCRC, sizeof(U32)); } if(success) @@ -84,27 +86,24 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) if(success) { success = check_read(apr_file, &mDupeCount, sizeof(S32)); -} + } if(success) -{ + { success = check_read(apr_file, &mCRCChangeCount, sizeof(S32)); } if(success) { success = check_read(apr_file, &size, sizeof(S32)); - // Corruption in the cache entries - if ((size > 10000) || (size < 1)) - { - // We've got a bogus size, skip reading it. - // We won't bother seeking, because the rest of this file - // is likely bogus, and will be tossed anyway. - llwarns << "Bogus cache entry, size " << size << ", aborting!" << llendl; - mLocalID = 0; - mCRC = 0; - mBuffer = NULL; - return; - } + // Corruption in the cache entries + if ((size > 10000) || (size < 1)) + { + // We've got a bogus size, skip reading it. + // We won't bother seeking, because the rest of this file + // is likely bogus, and will be tossed anyway. + llwarns << "Bogus cache entry, size " << size << ", aborting!" << llendl; + success = FALSE; + } } if(success && size > 0) { @@ -113,8 +112,8 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) if(success) { - mDP.assignBuffer(mBuffer, size); -} + mDP.assignBuffer(mBuffer, size); + } else { delete[] mBuffer ; @@ -126,6 +125,9 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) { mLocalID = 0; mCRC = 0; + mHitCount = 0; + mDupeCount = 0; + mCRCChangeCount = 0; mBuffer = NULL; } } @@ -258,7 +260,8 @@ void LLVOCache::destroyClass() LLVOCache::LLVOCache(): mInitialized(FALSE), mReadOnly(TRUE), - mNumEntries(0) + mNumEntries(0), + mCacheSize(1) { mEnabled = gSavedSettings.getBOOL("ObjectCacheEnabled"); mLocalAPRFilePoolp = new LLVolatileAPRPool() ; @@ -294,8 +297,8 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) { LLFile::mkdir(mObjectCacheDirName); } - mCacheSize = llmin(size, MAX_NUM_OBJECT_ENTRIES) ; - mCacheSize = llmax(mCacheSize, NUM_ENTRIES_TO_PURGE); + mCacheSize = llclamp(size, + MAX_NUM_OBJECT_ENTRIES, NUM_ENTRIES_TO_PURGE); mMetaInfo.mVersion = cache_version; readCacheHeader(); |