mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Deprecate TableVal::Delete(), replace with Remove()
This commit is contained in:
parent
087a0f3636
commit
dc03f0bb83
4 changed files with 34 additions and 12 deletions
|
@ -2550,7 +2550,7 @@ void IndexExpr::Delete(Frame* f)
|
||||||
if ( ! v2 )
|
if ( ! v2 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
v1->AsTableVal()->Delete(v2.get());
|
v1->AsTableVal()->Remove(*v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<Expr> IndexExpr::MakeLvalue()
|
IntrusivePtr<Expr> IndexExpr::MakeLvalue()
|
||||||
|
|
12
src/Val.cc
12
src/Val.cc
|
@ -1657,7 +1657,7 @@ bool TableVal::RemoveFrom(Val* val) const
|
||||||
// OTOH, they are both the same type, so as long as
|
// OTOH, they are both the same type, so as long as
|
||||||
// we don't have hash keys that are keyed per dictionary,
|
// we don't have hash keys that are keyed per dictionary,
|
||||||
// it should work ...
|
// it should work ...
|
||||||
t->Delete(k);
|
t->Remove(k);
|
||||||
delete k;
|
delete k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2089,16 +2089,16 @@ void TableVal::CallChangeFunc(const Val* index, Val* old_value, OnChangeType tpe
|
||||||
in_change_func = false;
|
in_change_func = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<Val> TableVal::Delete(const Val* index)
|
IntrusivePtr<Val> TableVal::Remove(const Val& index)
|
||||||
{
|
{
|
||||||
HashKey* k = ComputeHash(*index);
|
HashKey* k = ComputeHash(index);
|
||||||
TableEntryVal* v = k ? AsNonConstTable()->RemoveEntry(k) : nullptr;
|
TableEntryVal* v = k ? AsNonConstTable()->RemoveEntry(k) : nullptr;
|
||||||
IntrusivePtr<Val> va;
|
IntrusivePtr<Val> va;
|
||||||
|
|
||||||
if ( v )
|
if ( v )
|
||||||
va = v->GetVal() ? v->GetVal() : IntrusivePtr{NewRef{}, this};
|
va = v->GetVal() ? v->GetVal() : IntrusivePtr{NewRef{}, this};
|
||||||
|
|
||||||
if ( subnets && ! subnets->Remove(index) )
|
if ( subnets && ! subnets->Remove(&index) )
|
||||||
reporter->InternalWarning("index not in prefix table");
|
reporter->InternalWarning("index not in prefix table");
|
||||||
|
|
||||||
delete k;
|
delete k;
|
||||||
|
@ -2107,12 +2107,12 @@ IntrusivePtr<Val> TableVal::Delete(const Val* index)
|
||||||
Modified();
|
Modified();
|
||||||
|
|
||||||
if ( change_func )
|
if ( change_func )
|
||||||
CallChangeFunc(index, va.get(), ELEMENT_REMOVED);
|
CallChangeFunc(&index, va.get(), ELEMENT_REMOVED);
|
||||||
|
|
||||||
return va;
|
return va;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusivePtr<Val> TableVal::Delete(const HashKey* k)
|
IntrusivePtr<Val> TableVal::Remove(const HashKey* k)
|
||||||
{
|
{
|
||||||
TableEntryVal* v = AsNonConstTable()->RemoveEntry(k);
|
TableEntryVal* v = AsNonConstTable()->RemoveEntry(k);
|
||||||
IntrusivePtr<Val> va;
|
IntrusivePtr<Val> va;
|
||||||
|
|
28
src/Val.h
28
src/Val.h
|
@ -875,9 +875,31 @@ public:
|
||||||
// Returns the index corresponding to the given HashKey.
|
// Returns the index corresponding to the given HashKey.
|
||||||
IntrusivePtr<ListVal> RecoverIndex(const HashKey* k) const;
|
IntrusivePtr<ListVal> RecoverIndex(const HashKey* k) const;
|
||||||
|
|
||||||
// Returns the element if it was in the table, false otherwise.
|
/**
|
||||||
IntrusivePtr<Val> Delete(const Val* index);
|
* Remove an element from the table and return it.
|
||||||
IntrusivePtr<Val> Delete(const HashKey* k);
|
* @param index The index to remove.
|
||||||
|
* @return The value associated with the index if it exists, else nullptr.
|
||||||
|
* For a sets that don't really contain associated values, a placeholder
|
||||||
|
* value is returned to differentiate it from non-existent index (nullptr),
|
||||||
|
* but otherwise has no meaning in relation to the set's contents.
|
||||||
|
*/
|
||||||
|
IntrusivePtr<Val> Remove(const Val& index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as Remove(const Val&), but uses a precomputed hash key.
|
||||||
|
* @param k The hash key to lookup. This method takes ownership of
|
||||||
|
* deleting it.
|
||||||
|
* @return Same as Remove(const Val&).
|
||||||
|
*/
|
||||||
|
IntrusivePtr<Val> Remove(const HashKey* k);
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use Remove().")]]
|
||||||
|
Val* Delete(const Val* index)
|
||||||
|
{ return Remove(*index).release(); }
|
||||||
|
|
||||||
|
[[deprecated("Remove in v4.1. Use Remove().")]]
|
||||||
|
Val* Delete(const HashKey* k)
|
||||||
|
{ return Remove(k).release(); }
|
||||||
|
|
||||||
// Returns a ListVal representation of the table (which must be a set).
|
// Returns a ListVal representation of the table (which must be a set).
|
||||||
IntrusivePtr<ListVal> ToListVal(TypeTag t = TYPE_ANY) const;
|
IntrusivePtr<ListVal> ToListVal(TypeTag t = TYPE_ANY) const;
|
||||||
|
|
|
@ -1371,7 +1371,7 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
|
||||||
SendEvent(stream->event, 4, stream->description->Ref(), ev->Ref(),
|
SendEvent(stream->event, 4, stream->description->Ref(), ev->Ref(),
|
||||||
predidx->Ref(), val->Ref());
|
predidx->Ref(), val->Ref());
|
||||||
|
|
||||||
stream->tab->Delete(ih->idxkey);
|
stream->tab->Remove(ih->idxkey);
|
||||||
stream->lastDict->Remove(lastDictIdxKey); // delete in next line
|
stream->lastDict->Remove(lastDictIdxKey); // delete in next line
|
||||||
delete lastDictIdxKey;
|
delete lastDictIdxKey;
|
||||||
delete(ih);
|
delete(ih);
|
||||||
|
@ -1737,7 +1737,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value* *vals)
|
||||||
// only if stream = true -> no streaming
|
// only if stream = true -> no streaming
|
||||||
if ( streamresult )
|
if ( streamresult )
|
||||||
{
|
{
|
||||||
if ( ! stream->tab->Delete(idxval) )
|
if ( ! stream->tab->Remove(*idxval) )
|
||||||
Warning(i, "Internal error while deleting values from input table");
|
Warning(i, "Internal error while deleting values from input table");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue