summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-08 19:08:37 +0000
committerChris Lattner <sabre@nondot.org>2007-02-08 19:08:37 +0000
commit259ba20bd85186b3f51d35f58a7c3fde49f96750 (patch)
treebe2a226e1c7692111ff64ffab27a6bd956dce13c /llvm/lib
parent5d211e24d9adb67b8554b5d56de680349d008296 (diff)
downloadbcm5719-llvm-259ba20bd85186b3f51d35f58a7c3fde49f96750.tar.gz
bcm5719-llvm-259ba20bd85186b3f51d35f58a7c3fde49f96750.zip
Allow cstringmap to contain strings with nul characters in them.
llvm-svn: 34062
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Support/CStringMap.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Support/CStringMap.cpp b/llvm/lib/Support/CStringMap.cpp
index 31b50d2f154..b145e2ef81a 100644
--- a/llvm/lib/Support/CStringMap.cpp
+++ b/llvm/lib/Support/CStringMap.cpp
@@ -58,7 +58,7 @@ unsigned CStringMapImpl::LookupBucketFor(const char *NameStart,
unsigned ProbeAmt = 1;
while (1) {
ItemBucket &Bucket = TheTable[BucketNo];
- void *BucketItem = Bucket.Item;
+ StringMapEntryBase *BucketItem = Bucket.Item;
// If we found an empty bucket, this key isn't in the table yet, return it.
if (BucketItem == 0) {
Bucket.FullHashValue = FullHashValue;
@@ -73,8 +73,9 @@ unsigned CStringMapImpl::LookupBucketFor(const char *NameStart,
// Do the comparison like this because NameStart isn't necessarily
// null-terminated!
char *ItemStr = (char*)BucketItem+ItemSize;
- if (strlen(ItemStr) == unsigned(NameEnd-NameStart) &&
- memcmp(ItemStr, NameStart, (NameEnd-NameStart)) == 0) {
+ unsigned ItemStrLen = BucketItem->getKeyLength();
+ if (unsigned(NameEnd-NameStart) == ItemStrLen &&
+ memcmp(ItemStr, NameStart, ItemStrLen) == 0) {
// We found a match!
return BucketNo;
}
@@ -131,7 +132,7 @@ void CStringMapImpl::RehashTable() {
/// invoking Visitor.Visit for each of them.
void CStringMapImpl::VisitEntries(const CStringMapVisitor &Visitor) const {
for (ItemBucket *IB = TheTable, *E = TheTable+NumBuckets; IB != E; ++IB) {
- if (void *Id = IB->Item)
+ if (StringMapEntryBase *Id = IB->Item)
Visitor.Visit((char*)Id + ItemSize, Id);
}
}
OpenPOWER on IntegriCloud