mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix for the CompHash fix.
This commit is contained in:
parent
5dc96146f3
commit
03d41818e0
4 changed files with 18 additions and 10 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
|||
|
||||
1.6-dev-1120 | 2011-08-19 19:00:15 -0700
|
||||
|
||||
* Fix for the CompHash fix. (Robin Sommer)
|
||||
|
||||
1.6-dev-1118 | 2011-08-18 14:11:55 -0700
|
||||
|
||||
* Fixing key size calculation in composite hash code. (Robin Sommer)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.6-dev-1118
|
||||
1.6-dev-1120
|
||||
|
|
|
@ -47,7 +47,7 @@ CompositeHash::CompositeHash(TypeList* composite_type)
|
|||
|
||||
else
|
||||
{
|
||||
size = ComputeKeySize();
|
||||
size = ComputeKeySize(0, 1, true);
|
||||
|
||||
if ( size > 0 )
|
||||
// Fixed size. Make sure what we get is fully aligned.
|
||||
|
@ -244,7 +244,7 @@ HashKey* CompositeHash::ComputeHash(const Val* v, int type_check) const
|
|||
|
||||
if ( ! k )
|
||||
{
|
||||
int sz = ComputeKeySize(v, type_check);
|
||||
int sz = ComputeKeySize(v, type_check, false);
|
||||
if ( sz == 0 )
|
||||
return 0;
|
||||
|
||||
|
@ -331,7 +331,8 @@ HashKey* CompositeHash::ComputeSingletonHash(const Val* v, int type_check) const
|
|||
}
|
||||
|
||||
int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
||||
int type_check, int sz, bool optional) const
|
||||
int type_check, int sz, bool optional,
|
||||
bool calc_static_size) const
|
||||
{
|
||||
InternalTypeTag t = bt->InternalType();
|
||||
|
||||
|
@ -393,7 +394,8 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
|
||||
sz = SingleTypeKeySize(rt->FieldType(i),
|
||||
rv ? rv->Lookup(i) : 0,
|
||||
type_check, sz, v && optional);
|
||||
type_check, sz, optional,
|
||||
calc_static_size);
|
||||
if ( ! sz )
|
||||
return 0;
|
||||
}
|
||||
|
@ -408,7 +410,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
|
||||
case TYPE_INTERNAL_STRING:
|
||||
if ( ! v )
|
||||
return optional ? sz : 0;
|
||||
return (optional && ! calc_static_size) ? sz : 0;
|
||||
|
||||
// Factor in length field.
|
||||
sz = SizeAlign(sz, sizeof(int));
|
||||
|
@ -422,7 +424,7 @@ int CompositeHash::SingleTypeKeySize(BroType* bt, const Val* v,
|
|||
return sz;
|
||||
}
|
||||
|
||||
int CompositeHash::ComputeKeySize(const Val* v, int type_check) const
|
||||
int CompositeHash::ComputeKeySize(const Val* v, int type_check, bool calc_static_size) const
|
||||
{
|
||||
const type_list* tl = type->Types();
|
||||
const val_list* vl = 0;
|
||||
|
@ -440,7 +442,7 @@ int CompositeHash::ComputeKeySize(const Val* v, int type_check) const
|
|||
loop_over_list(*tl, i)
|
||||
{
|
||||
sz = SingleTypeKeySize((*tl)[i], v ? v->AsListVal()->Index(i) : 0,
|
||||
type_check, sz, false);
|
||||
type_check, sz, false, calc_static_size);
|
||||
if ( ! sz )
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -74,10 +74,12 @@ protected:
|
|||
// the value is computed for the particular list of values.
|
||||
// Returns 0 if the key has an indeterminant size (if v not given),
|
||||
// or if v doesn't match the index type (if given).
|
||||
int ComputeKeySize(const Val* v = 0, int type_check = 1) const;
|
||||
int ComputeKeySize(const Val* v, int type_check,
|
||||
bool calc_static_size) const;
|
||||
|
||||
int SingleTypeKeySize(BroType*, const Val*,
|
||||
int type_check, int sz, bool optional) const;
|
||||
int type_check, int sz, bool optional,
|
||||
bool calc_static_size) const;
|
||||
|
||||
TypeList* type;
|
||||
char* key; // space for composite key
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue