mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-24 12:15:51 -04:00
Allow cstringmap to contain strings with nul characters in them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34062 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user