cwUi.cpp :
1. Add one to hashA[] to prevent a hash index of 0xffff from going past the end of the array. 2. Fix bug where hash table buckets were not released.
This commit is contained in:
parent
43c5be958a
commit
89a4b83c45
20
cwUi.cpp
20
cwUi.cpp
@ -117,7 +117,7 @@ namespace cw
|
|||||||
unsigned sentMsgN;
|
unsigned sentMsgN;
|
||||||
unsigned recvMsgN;
|
unsigned recvMsgN;
|
||||||
|
|
||||||
bucket_t hashA[ hashN ];
|
bucket_t hashA[ hashN+1 ];
|
||||||
|
|
||||||
} ui_t;
|
} ui_t;
|
||||||
|
|
||||||
@ -129,7 +129,11 @@ namespace cw
|
|||||||
assert( parentUuId != kInvalidId && appId != kInvalidId );
|
assert( parentUuId != kInvalidId && appId != kInvalidId );
|
||||||
unsigned hc = parentUuId + cwSwap32(appId);
|
unsigned hc = parentUuId + cwSwap32(appId);
|
||||||
|
|
||||||
return (unsigned short)(((hc & 0xffff0000)>>16) + (hc & 0x0000ffff));
|
unsigned short hash_idx = (unsigned short)(((hc & 0xffff0000)>>16) + (hc & 0x0000ffff));
|
||||||
|
|
||||||
|
assert( hash_idx <= hashN );
|
||||||
|
|
||||||
|
return hash_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,6 +229,18 @@ namespace cw
|
|||||||
m = m0;
|
m = m0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: hashA[] has hashN+1 elements
|
||||||
|
for(unsigned i=0; i<=hashN; ++i)
|
||||||
|
{
|
||||||
|
bucket_t* b = p->hashA[i].link;
|
||||||
|
while( b!=nullptr )
|
||||||
|
{
|
||||||
|
bucket_t* b0 = b->link;
|
||||||
|
mem::release(b);
|
||||||
|
b = b0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mem::release(p->sessA);
|
mem::release(p->sessA);
|
||||||
mem::release(p->eleA);
|
mem::release(p->eleA);
|
||||||
mem::release(p->buf);
|
mem::release(p->buf);
|
||||||
|
Loading…
Reference in New Issue
Block a user