summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.h
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2011-09-02 11:17:03 -0600
committerXiaohong Bao <bao@lindenlab.com>2011-09-02 11:17:03 -0600
commitba2ae6bc9583420a07245b4a7af2a779fb02b6c9 (patch)
treede5fe2fa54e448e613aa70a1f16b7907b3441084 /indra/llcommon/llmemory.h
parent1379188c82a49617782288a61f1c3908d8738a3e (diff)
re-write the hash table code to eliminate potential flaws and simplify the implementation.
Diffstat (limited to 'indra/llcommon/llmemory.h')
-rw-r--r--indra/llcommon/llmemory.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index f9099da612..db753f0d8b 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -300,8 +300,6 @@ public:
//form a linked list
LLMemoryChunk* mNext ;
LLMemoryChunk* mPrev ;
-
- LLMemoryChunk* mHashNext ;
} ;
private:
@@ -356,12 +354,30 @@ private:
U32 mMaxPoolSize;
U32 mReservedPoolSize ;
- LLMemoryChunk* mChunkList[SUPER_ALLOCATION] ; //all memory chunks reserved by this pool, sorted by address
- std::vector<LLMemoryChunk*> mChunkHashList ;
+ LLMemoryChunk* mChunkList[SUPER_ALLOCATION] ; //all memory chunks reserved by this pool, sorted by address
U16 mNumOfChunks ;
U16 mHashFactor ;
S32 mType ;
+
+ class LLChunkHashElement
+ {
+ public:
+ LLChunkHashElement() {mFirst = NULL ; mSecond = NULL ;}
+
+ bool add(LLMemoryChunk* chunk) ;
+ void remove(LLMemoryChunk* chunk) ;
+ LLMemoryChunk* findChunk(const char* addr) ;
+
+ bool empty() {return !mFirst && !mSecond; }
+ bool full() {return mFirst && mSecond; }
+ bool hasElement(LLMemoryChunk* chunk) {return mFirst == chunk || mSecond == chunk;}
+
+ private:
+ LLMemoryChunk* mFirst ;
+ LLMemoryChunk* mSecond ;
+ };
+ std::vector<LLChunkHashElement> mChunkHashList ;
};
class LL_COMMON_API LLPrivateMemoryPoolManager