Move Dictionary/PDict, List/PList, and Queue/PQueue to zeek namespace

This commit is contained in:
Tim Wojtulewicz 2020-06-23 13:25:43 -07:00
parent 4a1e17f4e0
commit 464efbe66a
30 changed files with 172 additions and 138 deletions

View file

@ -5,23 +5,23 @@
#include "List.h" #include "List.h"
ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek); ZEEK_FORWARD_DECLARE_NAMESPACED(Val, zeek);
using val_list = PList<zeek::Val>; using val_list = zeek::PList<zeek::Val>;
ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Expr, zeek::detail);
using expr_list = PList<zeek::detail::Expr>; using expr_list = zeek::PList<zeek::detail::Expr>;
ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(ID, zeek::detail);
using id_list = PList<zeek::detail::ID>; using id_list = zeek::PList<zeek::detail::ID>;
ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Stmt, zeek::detail);
using stmt_list = PList<zeek::detail::Stmt>; using stmt_list = zeek::PList<zeek::detail::Stmt>;
namespace zeek { class Type; } namespace zeek { class Type; }
using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type; using BroType [[deprecated("Remove in v4.1. Use zeek::Type instead.")]] = zeek::Type;
using type_list = PList<zeek::Type>; using type_list = zeek::PList<zeek::Type>;
ZEEK_FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Attr, zeek::detail);
using attr_list = PList<zeek::detail::Attr>; using attr_list = zeek::PList<zeek::detail::Attr>;
class Timer; class Timer;
using timer_list = PList<Timer, ListOrder::UNORDERED>; using timer_list = zeek::PList<Timer, zeek::ListOrder::UNORDERED>;

View file

@ -49,7 +49,6 @@ private:
int current_level; int current_level;
int suspend_level; int suspend_level;
typedef PList<void> voidp_list; using voidp_list = zeek::PList<void>;
voidp_list states; voidp_list states;
}; };

View file

@ -29,8 +29,7 @@ using ListValPtr = zeek::IntrusivePtr<ListVal>;
using TableValPtr = zeek::IntrusivePtr<TableVal>; using TableValPtr = zeek::IntrusivePtr<TableVal>;
} }
using DNS_mgr_request_list = zeek::PList<DNS_Mgr_Request>;
typedef PList<DNS_Mgr_Request> DNS_mgr_request_list;
struct nb_dns_info; struct nb_dns_info;
struct nb_dns_result; struct nb_dns_result;

View file

@ -30,7 +30,7 @@ struct ParseLocationRec {
}; };
class StmtLocMapping; class StmtLocMapping;
typedef PQueue<StmtLocMapping> Filemap; // mapping for a single file typedef zeek::PQueue<StmtLocMapping> Filemap; // mapping for a single file
class DbgBreakpoint; class DbgBreakpoint;
class DbgWatch; class DbgWatch;

View file

@ -123,7 +123,7 @@ static void choose_global_symbols_regex(const string& regex, vector<zeek::detail
// DebugCmdInfo implementation // DebugCmdInfo implementation
// //
PQueue<DebugCmdInfo> g_DebugCmdInfos; zeek::PQueue<DebugCmdInfo> g_DebugCmdInfos;
DebugCmdInfo::DebugCmdInfo(const DebugCmdInfo& info) DebugCmdInfo::DebugCmdInfo(const DebugCmdInfo& info)
: cmd(info.cmd), helpstring(nullptr) : cmd(info.cmd), helpstring(nullptr)

View file

@ -41,7 +41,7 @@ protected:
bool repeatable; bool repeatable;
}; };
extern PQueue<DebugCmdInfo> g_DebugCmdInfos; extern zeek::PQueue<DebugCmdInfo> g_DebugCmdInfos;
void init_global_dbg_constants (); void init_global_dbg_constants ();

View file

@ -13,17 +13,18 @@
// If the mean bucket length exceeds the following then Insert() will // If the mean bucket length exceeds the following then Insert() will
// increase the size of the hash table. // increase the size of the hash table.
#define DEFAULT_DENSITY_THRESH 3.0 constexpr double DEFAULT_DENSITY_THRESH = 3.0;
// Threshold above which we do not try to ensure that the hash size // Threshold above which we do not try to ensure that the hash size
// is prime. // is prime.
#define PRIME_THRESH 1000 constexpr int PRIME_THRESH = 1000;
// Default number of hash buckets in dictionary. The dictionary will // Default number of hash buckets in dictionary. The dictionary will
// increase the size of the hash table as needed. // increase the size of the hash table as needed.
#define DEFAULT_DICT_SIZE 16 constexpr int DEFAULT_DICT_SIZE = 16;
TEST_SUITE_BEGIN("Dict"); namespace zeek {
namespace detail {
class DictEntry { class DictEntry {
public: public:
@ -40,6 +41,8 @@ public:
void* value; void* value;
}; };
} //namespace detail
// The value of an iteration cookie is the bucket and offset within the // The value of an iteration cookie is the bucket and offset within the
// bucket at which to start looking for the next value to return. // bucket at which to start looking for the next value to return.
class IterCookie { class IterCookie {
@ -47,25 +50,29 @@ public:
IterCookie(int b, int o) : bucket(b), offset(o) {} IterCookie(int b, int o) : bucket(b), offset(o) {}
int bucket, offset; int bucket, offset;
PList<DictEntry>** ttbl = nullptr; zeek::PList<detail::DictEntry>** ttbl = nullptr;
const int* num_buckets_p = nullptr; const int* num_buckets_p = nullptr;
PList<DictEntry> inserted; // inserted while iterating zeek::PList<detail::DictEntry> inserted; // inserted while iterating
}; };
} // namespace zeek
TEST_SUITE_BEGIN("Dict");
TEST_CASE("dict construction") TEST_CASE("dict construction")
{ {
PDict<int> dict; zeek::PDict<int> dict;
CHECK(dict.IsOrdered() == false); CHECK(dict.IsOrdered() == false);
CHECK(dict.Length() == 0); CHECK(dict.Length() == 0);
PDict<int> dict2(ORDERED); zeek::PDict<int> dict2(zeek::ORDERED);
CHECK(dict2.IsOrdered() == true); CHECK(dict2.IsOrdered() == true);
CHECK(dict2.Length() == 0); CHECK(dict2.Length() == 0);
} }
TEST_CASE("dict operation") TEST_CASE("dict operation")
{ {
PDict<uint32_t> dict; zeek::PDict<uint32_t> dict;
uint32_t val = 10; uint32_t val = 10;
uint32_t key_val = 5; uint32_t key_val = 5;
@ -111,8 +118,8 @@ TEST_CASE("dict operation")
TEST_CASE("dict nthentry") TEST_CASE("dict nthentry")
{ {
PDict<uint32_t> unordered(UNORDERED); zeek::PDict<uint32_t> unordered(zeek::UNORDERED);
PDict<uint32_t> ordered(ORDERED); zeek::PDict<uint32_t> ordered(zeek::ORDERED);
uint32_t val = 15; uint32_t val = 15;
uint32_t key_val = 5; uint32_t key_val = 5;
@ -147,7 +154,7 @@ TEST_CASE("dict nthentry")
TEST_CASE("dict iteration") TEST_CASE("dict iteration")
{ {
PDict<uint32_t> dict; zeek::PDict<uint32_t> dict;
uint32_t val = 15; uint32_t val = 15;
uint32_t key_val = 5; uint32_t key_val = 5;
@ -161,7 +168,7 @@ TEST_CASE("dict iteration")
dict.Insert(key2, &val2); dict.Insert(key2, &val2);
HashKey* it_key; HashKey* it_key;
IterCookie* it = dict.InitForIteration(); zeek::IterCookie* it = dict.InitForIteration();
CHECK(it != nullptr); CHECK(it != nullptr);
int count = 0; int count = 0;
@ -186,10 +193,14 @@ TEST_CASE("dict iteration")
delete key2; delete key2;
} }
Dictionary::Dictionary(dict_order ordering, int initial_size) TEST_SUITE_END();
namespace zeek {
Dictionary::Dictionary(DictOrder ordering, int initial_size)
{ {
if ( ordering == ORDERED ) if ( ordering == ORDERED )
order = new PList<DictEntry>; order = new zeek::PList<detail::DictEntry>;
if ( initial_size > 0 ) if ( initial_size > 0 )
Init(initial_size); Init(initial_size);
@ -218,7 +229,7 @@ void Dictionary::DeInit()
for ( int i = 0; i < num_buckets; ++i ) for ( int i = 0; i < num_buckets; ++i )
if ( tbl[i] ) if ( tbl[i] )
{ {
PList<DictEntry>* chain = tbl[i]; zeek::PList<detail::DictEntry>* chain = tbl[i];
for ( const auto& e : *chain ) for ( const auto& e : *chain )
{ {
if ( delete_func ) if ( delete_func )
@ -238,7 +249,7 @@ void Dictionary::DeInit()
for ( int i = 0; i < num_buckets2; ++i ) for ( int i = 0; i < num_buckets2; ++i )
if ( tbl2[i] ) if ( tbl2[i] )
{ {
PList<DictEntry>* chain = tbl2[i]; zeek::PList<detail::DictEntry>* chain = tbl2[i];
for ( const auto& e : *chain ) for ( const auto& e : *chain )
{ {
if ( delete_func ) if ( delete_func )
@ -259,7 +270,7 @@ void* Dictionary::Lookup(const void* key, int key_size, hash_t hash) const
return nullptr; return nullptr;
hash_t h; hash_t h;
PList<DictEntry>* chain; zeek::PList<detail::DictEntry>* chain;
// Figure out which hash table to look in. // Figure out which hash table to look in.
h = hash % num_buckets; h = hash % num_buckets;
@ -287,12 +298,12 @@ void* Dictionary::Insert(void* key, int key_size, hash_t hash, void* val,
if ( ! tbl ) if ( ! tbl )
Init(DEFAULT_DICT_SIZE); Init(DEFAULT_DICT_SIZE);
DictEntry* new_entry = new DictEntry(key, key_size, hash, val); detail::DictEntry* new_entry = new detail::DictEntry(key, key_size, hash, val);
void* old_val = Insert(new_entry, copy_key); void* old_val = Insert(new_entry, copy_key);
if ( old_val ) if ( old_val )
{ {
// We didn't need the new DictEntry, the key was already // We didn't need the new detail::DictEntry, the key was already
// present. // present.
delete new_entry; delete new_entry;
} }
@ -315,7 +326,7 @@ void* Dictionary::Remove(const void* key, int key_size, hash_t hash,
return nullptr; return nullptr;
hash_t h; hash_t h;
PList<DictEntry>* chain; zeek::PList<detail::DictEntry>* chain;
int* num_entries_ptr; int* num_entries_ptr;
// Figure out which hash table to look in // Figure out which hash table to look in
@ -338,7 +349,7 @@ void* Dictionary::Remove(const void* key, int key_size, hash_t hash,
for ( auto i = 0u; i < chain_length; ++i ) for ( auto i = 0u; i < chain_length; ++i )
{ {
DictEntry* entry = (*chain)[i]; detail::DictEntry* entry = (*chain)[i];
if ( entry->hash == hash && entry->len == key_size && if ( entry->hash == hash && entry->len == key_size &&
! memcmp(key, entry->key, key_size) ) ! memcmp(key, entry->key, key_size) )
@ -357,8 +368,8 @@ void* Dictionary::Remove(const void* key, int key_size, hash_t hash,
return nullptr; return nullptr;
} }
void* Dictionary::DoRemove(DictEntry* entry, hash_t h, void* Dictionary::DoRemove(detail::DictEntry* entry, hash_t h,
PList<DictEntry>* chain, int chain_offset) zeek::PList<detail::DictEntry>* chain, int chain_offset)
{ {
void* entry_value = entry->value; void* entry_value = entry->value;
@ -397,7 +408,7 @@ void* Dictionary::NthEntry(int n, const void*& key, int& key_len) const
if ( ! order || n < 0 || n >= Length() ) if ( ! order || n < 0 || n >= Length() )
return nullptr; return nullptr;
DictEntry* entry = (*order)[n]; detail::DictEntry* entry = (*order)[n];
key = entry->key; key = entry->key;
key_len = entry->len; key_len = entry->len;
return entry->value; return entry->value;
@ -417,7 +428,7 @@ void* Dictionary::NextEntry(HashKey*& h, IterCookie*& cookie, int return_hash) c
{ {
if ( ! tbl && ! tbl2 ) if ( ! tbl && ! tbl2 )
{ {
const_cast<PList<IterCookie>*>(&cookies)->remove(cookie); const_cast<zeek::PList<IterCookie>*>(&cookies)->remove(cookie);
delete cookie; delete cookie;
cookie = nullptr; cookie = nullptr;
return nullptr; return nullptr;
@ -427,7 +438,7 @@ void* Dictionary::NextEntry(HashKey*& h, IterCookie*& cookie, int return_hash) c
// That keeps the list small and helps avoiding searching // That keeps the list small and helps avoiding searching
// a large list when deleting an entry. // a large list when deleting an entry.
DictEntry* entry; detail::DictEntry* entry;
if ( cookie->inserted.length() ) if ( cookie->inserted.length() )
{ {
@ -442,7 +453,7 @@ void* Dictionary::NextEntry(HashKey*& h, IterCookie*& cookie, int return_hash) c
int b = cookie->bucket; int b = cookie->bucket;
int o = cookie->offset; int o = cookie->offset;
PList<DictEntry>** ttbl; zeek::PList<detail::DictEntry>** ttbl;
const int* num_buckets_p; const int* num_buckets_p;
if ( ! cookie->ttbl ) if ( ! cookie->ttbl )
@ -484,7 +495,7 @@ void* Dictionary::NextEntry(HashKey*& h, IterCookie*& cookie, int return_hash) c
// FIXME: I don't like removing the const here. But is there // FIXME: I don't like removing the const here. But is there
// a better way? // a better way?
const_cast<PList<IterCookie>*>(&cookies)->remove(cookie); const_cast<zeek::PList<IterCookie>*>(&cookies)->remove(cookie);
delete cookie; delete cookie;
cookie = nullptr; cookie = nullptr;
return nullptr; return nullptr;
@ -503,7 +514,7 @@ void* Dictionary::NextEntry(HashKey*& h, IterCookie*& cookie, int return_hash) c
void Dictionary::Init(int size) void Dictionary::Init(int size)
{ {
num_buckets = NextPrime(size); num_buckets = NextPrime(size);
tbl = new PList<DictEntry>*[num_buckets]; tbl = new zeek::PList<detail::DictEntry>*[num_buckets];
for ( int i = 0; i < num_buckets; ++i ) for ( int i = 0; i < num_buckets; ++i )
tbl[i] = nullptr; tbl[i] = nullptr;
@ -515,7 +526,7 @@ void Dictionary::Init(int size)
void Dictionary::Init2(int size) void Dictionary::Init2(int size)
{ {
num_buckets2 = NextPrime(size); num_buckets2 = NextPrime(size);
tbl2 = new PList<DictEntry>*[num_buckets2]; tbl2 = new zeek::PList<detail::DictEntry>*[num_buckets2];
for ( int i = 0; i < num_buckets2; ++i ) for ( int i = 0; i < num_buckets2; ++i )
tbl2[i] = nullptr; tbl2[i] = nullptr;
@ -524,12 +535,12 @@ void Dictionary::Init2(int size)
} }
// private // private
void* Dictionary::Insert(DictEntry* new_entry, bool copy_key) void* Dictionary::Insert(detail::DictEntry* new_entry, bool copy_key)
{ {
if ( ! tbl ) if ( ! tbl )
Init(DEFAULT_DICT_SIZE); Init(DEFAULT_DICT_SIZE);
PList<DictEntry>** ttbl; zeek::PList<detail::DictEntry>** ttbl;
int* num_entries_ptr; int* num_entries_ptr;
int* max_num_entries_ptr; int* max_num_entries_ptr;
hash_t h = new_entry->hash % num_buckets; hash_t h = new_entry->hash % num_buckets;
@ -554,7 +565,7 @@ void* Dictionary::Insert(DictEntry* new_entry, bool copy_key)
max_num_entries_ptr = &max_num_entries2; max_num_entries_ptr = &max_num_entries2;
} }
PList<DictEntry>* chain = ttbl[h]; zeek::PList<detail::DictEntry>* chain = ttbl[h];
int n = new_entry->len; int n = new_entry->len;
@ -562,7 +573,7 @@ void* Dictionary::Insert(DictEntry* new_entry, bool copy_key)
{ {
for ( int i = 0; i < chain->length(); ++i ) for ( int i = 0; i < chain->length(); ++i )
{ {
DictEntry* entry = (*chain)[i]; detail::DictEntry* entry = (*chain)[i];
if ( entry->hash == new_entry->hash && if ( entry->hash == new_entry->hash &&
entry->len == n && entry->len == n &&
@ -576,7 +587,7 @@ void* Dictionary::Insert(DictEntry* new_entry, bool copy_key)
} }
else else
// Create new chain. // Create new chain.
chain = ttbl[h] = new PList<DictEntry>; chain = ttbl[h] = new zeek::PList<detail::DictEntry>;
// If we got this far, then we couldn't use an existing copy // If we got this far, then we couldn't use an existing copy
// of the key, so make a new one if necessary. // of the key, so make a new one if necessary.
@ -660,7 +671,7 @@ void Dictionary::MoveChains()
do do
{ {
PList<DictEntry>* chain = tbl[tbl_next_ind++]; zeek::PList<detail::DictEntry>* chain = tbl[tbl_next_ind++];
if ( ! chain ) if ( ! chain )
continue; continue;
@ -720,13 +731,13 @@ unsigned int Dictionary::MemoryAllocation() const
for ( int i = 0; i < num_buckets; ++i ) for ( int i = 0; i < num_buckets; ++i )
if ( tbl[i] ) if ( tbl[i] )
{ {
PList<DictEntry>* chain = tbl[i]; zeek::PList<detail::DictEntry>* chain = tbl[i];
for ( const auto& c : *chain ) for ( const auto& c : *chain )
size += padded_sizeof(DictEntry) + pad_size(c->len); size += padded_sizeof(detail::DictEntry) + pad_size(c->len);
size += chain->MemoryAllocation(); size += chain->MemoryAllocation();
} }
size += pad_size(num_buckets * sizeof(PList<DictEntry>*)); size += pad_size(num_buckets * sizeof(zeek::PList<detail::DictEntry>*));
if ( order ) if ( order )
size += order->MemoryAllocation(); size += order->MemoryAllocation();
@ -736,13 +747,13 @@ unsigned int Dictionary::MemoryAllocation() const
for ( int i = 0; i < num_buckets2; ++i ) for ( int i = 0; i < num_buckets2; ++i )
if ( tbl2[i] ) if ( tbl2[i] )
{ {
PList<DictEntry>* chain = tbl2[i]; zeek::PList<detail::DictEntry>* chain = tbl2[i];
for ( const auto& c : *chain ) for ( const auto& c : *chain )
size += padded_sizeof(DictEntry) + pad_size(c->len); size += padded_sizeof(detail::DictEntry) + pad_size(c->len);
size += chain->MemoryAllocation(); size += chain->MemoryAllocation();
} }
size += pad_size(num_buckets2 * sizeof(PList<DictEntry>*)); size += pad_size(num_buckets2 * sizeof(zeek::PList<detail::DictEntry>*));
} }
return size; return size;
@ -753,4 +764,4 @@ void generic_delete_func(void* v)
free(v); free(v);
} }
TEST_SUITE_END(); } // namespace zeek

View file

@ -2,27 +2,31 @@
#pragma once #pragma once
#include "zeek-config.h"
#include "List.h" #include "List.h"
#include "Hash.h" #include "Hash.h"
class Dictionary; ZEEK_FORWARD_DECLARE_NAMESPACED(DictEntry, zeek::detail);
class DictEntry; ZEEK_FORWARD_DECLARE_NAMESPACED(IterCookie, zeek);
class IterCookie;
// Type indicating whether the dictionary should keep track of the order
// of insertions.
enum dict_order { ORDERED, UNORDERED };
// Type for function to be called when deleting elements. // Type for function to be called when deleting elements.
typedef void (*dict_delete_func)(void*); typedef void (*dict_delete_func)(void*);
namespace zeek {
// Type indicating whether the dictionary should keep track of the order
// of insertions.
enum DictOrder { ORDERED, UNORDERED };
// A dict_delete_func that just calls delete. // A dict_delete_func that just calls delete.
extern void generic_delete_func(void*); extern void generic_delete_func(void*);
class Dictionary { class Dictionary {
public: public:
explicit Dictionary(dict_order ordering = UNORDERED, explicit Dictionary(DictOrder ordering = UNORDERED,
int initial_size = 0); int initial_size = 0);
~Dictionary(); ~Dictionary();
// Member functions for looking up a key, inserting/changing its // Member functions for looking up a key, inserting/changing its
@ -125,10 +129,10 @@ private:
void DeInit(); void DeInit();
// Internal version of Insert(). // Internal version of Insert().
void* Insert(DictEntry* entry, bool copy_key); void* Insert(zeek::detail::DictEntry* entry, bool copy_key);
void* DoRemove(DictEntry* entry, hash_t h, void* DoRemove(zeek::detail::DictEntry* entry, hash_t h,
PList<DictEntry>* chain, int chain_offset); zeek::PList<zeek::detail::DictEntry>* chain, int chain_offset);
int NextPrime(int n) const; int NextPrime(int n) const;
bool IsPrime(int n) const; bool IsPrime(int n) const;
@ -158,7 +162,7 @@ private:
// When we're resizing, we'll have tbl (old) and tbl2 (new) // When we're resizing, we'll have tbl (old) and tbl2 (new)
// tbl_next_ind keeps track of how much we've moved to tbl2 // tbl_next_ind keeps track of how much we've moved to tbl2
// (it's the next index we're going to move). // (it's the next index we're going to move).
PList<DictEntry>** tbl = nullptr; zeek::PList<zeek::detail::DictEntry>** tbl = nullptr;
int num_buckets = 0; int num_buckets = 0;
int num_entries = 0; int num_entries = 0;
int max_num_entries = 0; int max_num_entries = 0;
@ -167,7 +171,7 @@ private:
double den_thresh = 0.0; double den_thresh = 0.0;
// Resizing table (replicates tbl above). // Resizing table (replicates tbl above).
PList<DictEntry>** tbl2 = nullptr; zeek::PList<zeek::detail::DictEntry>** tbl2 = nullptr;
int num_buckets2 = 0; int num_buckets2 = 0;
int num_entries2 = 0; int num_entries2 = 0;
int max_num_entries2 = 0; int max_num_entries2 = 0;
@ -177,16 +181,16 @@ private:
hash_t tbl_next_ind = 0; hash_t tbl_next_ind = 0;
PList<DictEntry>* order = nullptr; zeek::PList<zeek::detail::DictEntry>* order = nullptr;
dict_delete_func delete_func = nullptr; dict_delete_func delete_func = nullptr;
PList<IterCookie> cookies; zeek::PList<IterCookie> cookies;
}; };
template<typename T> template<typename T>
class PDict : public Dictionary { class PDict : public Dictionary {
public: public:
explicit PDict(dict_order ordering = UNORDERED, int initial_size = 0) : explicit PDict(DictOrder ordering = UNORDERED, int initial_size = 0) :
Dictionary(ordering, initial_size) {} Dictionary(ordering, initial_size) {}
T* Lookup(const char* key) const T* Lookup(const char* key) const
{ {
@ -221,3 +225,8 @@ public:
T* RemoveEntry(const HashKey& key) T* RemoveEntry(const HashKey& key)
{ return (T*) Remove(key.Key(), key.Size(), key.Hash()); } { return (T*) Remove(key.Key(), key.Size(), key.Hash()); }
}; };
} //namespace zeek
using Dictionary [[deprecated("Remove in v4.1. Use zeek::Dictionary instead.")]] = zeek::Dictionary;
template<typename T> using PDict [[deprecated("Remove in v4.1. Use zeek::PDict instead.")]] = zeek::PDict<T>;

View file

@ -3,17 +3,17 @@
TEST_CASE("list construction") TEST_CASE("list construction")
{ {
List<int> list; zeek::List<int> list;
CHECK(list.empty()); CHECK(list.empty());
List<int> list2(10); zeek::List<int> list2(10);
CHECK(list2.empty()); CHECK(list2.empty());
CHECK(list2.max() == 10); CHECK(list2.max() == 10);
} }
TEST_CASE("list operation") TEST_CASE("list operation")
{ {
List<int> list({ 1, 2, 3 }); zeek::List<int> list({ 1, 2, 3 });
CHECK(list.size() == 3); CHECK(list.size() == 3);
CHECK(list.max() == 3); CHECK(list.max() == 3);
CHECK(list[0] == 1); CHECK(list[0] == 1);
@ -85,7 +85,7 @@ TEST_CASE("list operation")
TEST_CASE("list iteration") TEST_CASE("list iteration")
{ {
List<int> list({ 1, 2, 3, 4}); zeek::List<int> list({ 1, 2, 3, 4});
int index = 1; int index = 1;
for ( int v : list ) for ( int v : list )
@ -98,7 +98,7 @@ TEST_CASE("list iteration")
TEST_CASE("plists") TEST_CASE("plists")
{ {
PList<int> list; zeek::PList<int> list;
list.push_back(new int(1)); list.push_back(new int(1));
list.push_back(new int(2)); list.push_back(new int(2));
list.push_back(new int(3)); list.push_back(new int(3));
@ -117,7 +117,7 @@ TEST_CASE("plists")
TEST_CASE("unordered list operation") TEST_CASE("unordered list operation")
{ {
List<int, ListOrder::UNORDERED> list({1, 2, 3, 4}); zeek::List<int, zeek::ListOrder::UNORDERED> list({1, 2, 3, 4});
CHECK(list.size() == 4); CHECK(list.size() == 4);
// An unordered list doesn't maintain the ordering of the elements when // An unordered list doesn't maintain the ordering of the elements when

View file

@ -26,6 +26,10 @@
#include <cassert> #include <cassert>
#include "util.h" #include "util.h"
//enum class [[deprecated("Remove in v4.1. Use zeek::ListOrder instead.")]] ListOrder : int { ORDERED, UNORDERED };
namespace zeek {
enum class ListOrder : int { ORDERED, UNORDERED }; enum class ListOrder : int { ORDERED, UNORDERED };
template<typename T, ListOrder Order = ListOrder::ORDERED> template<typename T, ListOrder Order = ListOrder::ORDERED>
@ -331,7 +335,11 @@ template<typename T, ListOrder Order = ListOrder::ORDERED>
using PList = List<T*, Order>; using PList = List<T*, Order>;
// Popular type of list: list of strings. // Popular type of list: list of strings.
typedef PList<char> name_list; using name_list = PList<char>;
} // namespace zeek
using ListOrder [[deprecated("Remove in v4.1. Use zeek::ListOrder instead.")]] = zeek::ListOrder;
// Macro to visit each list element in turn. // Macro to visit each list element in turn.
#define loop_over_list(list, iterator) \ #define loop_over_list(list, iterator) \

View file

@ -11,7 +11,7 @@ class EquivClass;
ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail); ZEEK_FORWARD_DECLARE_NAMESPACED(Func, zeek::detail);
typedef PList<NFA_State> NFA_state_list; using NFA_state_list = zeek::PList<NFA_State>;
#define NO_ACCEPT 0 #define NO_ACCEPT 0

View file

@ -22,6 +22,7 @@
// Entries must be either a pointer to the data or nonzero data with // Entries must be either a pointer to the data or nonzero data with
// sizeof(data) <= sizeof(void*). // sizeof(data) <= sizeof(void*).
namespace zeek {
template<typename T> template<typename T>
class Queue { class Queue {
@ -196,3 +197,8 @@ protected:
template<typename T> template<typename T>
using PQueue = Queue<T*>; using PQueue = Queue<T*>;
} // namespace zeek
template<typename T> using Queue [[deprecated("Remove in v4.1. Use zeek::Queue instead.")]] = zeek::Queue<T>;
template<typename T> using PQueue [[deprecated("Remove in v4.1. Use zeek::Queue instead.")]] = zeek::PQueue<T>;

View file

@ -36,7 +36,7 @@ typedef int AcceptIdx;
typedef std::set<AcceptIdx> AcceptingSet; typedef std::set<AcceptIdx> AcceptingSet;
typedef uint64_t MatchPos; typedef uint64_t MatchPos;
typedef std::map<AcceptIdx, MatchPos> AcceptingMatchSet; typedef std::map<AcceptIdx, MatchPos> AcceptingMatchSet;
typedef name_list string_list; typedef zeek::name_list string_list;
typedef enum { MATCH_ANYWHERE, MATCH_EXACTLY, } match_type; typedef enum { MATCH_ANYWHERE, MATCH_EXACTLY, } match_type;
@ -128,7 +128,7 @@ protected:
std::map<std::string, std::string> defs; std::map<std::string, std::string> defs;
std::map<std::string, CCL*> ccl_dict; std::map<std::string, CCL*> ccl_dict;
PList<CCL> ccl_list; zeek::PList<CCL> ccl_list;
EquivClass equiv_class; EquivClass equiv_class;
int* ecs; int* ecs;
DFA_Machine* dfa; DFA_Machine* dfa;

View file

@ -73,7 +73,7 @@ void Reporter::InitOptions()
auto wl_table = wl_val->AsTable(); auto wl_table = wl_val->AsTable();
HashKey* k; HashKey* k;
IterCookie* c = wl_table->InitForIteration(); zeek::IterCookie* c = wl_table->InitForIteration();
zeek::TableEntryVal* v; zeek::TableEntryVal* v;
while ( (v = wl_table->NextEntry(k, c)) ) while ( (v = wl_table->NextEntry(k, c)) )

View file

@ -14,8 +14,8 @@ class RuleAction;
class RuleHdrTest; class RuleHdrTest;
class Rule; class Rule;
typedef PList<Rule> rule_list; using rule_list = zeek::PList<Rule>;
typedef std::map<std::string, Rule*> rule_dict; using rule_dict = std::map<std::string, Rule*>;
class Rule { class Rule {
public: public:
@ -58,9 +58,9 @@ private:
void SortHdrTests(); void SortHdrTests();
typedef PList<RuleAction> rule_action_list; using rule_action_list = zeek::PList<RuleAction>;
typedef PList<RuleCondition> rule_condition_list; using rule_condition_list = zeek::PList<RuleCondition>;
typedef PList<RuleHdrTest> rule_hdr_test_list; using rule_hdr_test_list = zeek::PList<RuleHdrTest>;
rule_hdr_test_list hdr_tests; rule_hdr_test_list hdr_tests;
rule_condition_list conditions; rule_condition_list conditions;
@ -74,7 +74,7 @@ private:
bool negate; // negate test bool negate; // negate test
}; };
typedef PList<Precond> precond_list; using precond_list = zeek::PList<Precond>;
precond_list preconds; precond_list preconds;
rule_list dependents; // rules w/ us as a precondition rule_list dependents; // rules w/ us as a precondition
@ -92,7 +92,7 @@ private:
uint32_t depth; uint32_t depth;
}; };
typedef PList<Pattern> pattern_list; using pattern_list = zeek::PList<Pattern>;
pattern_list patterns; pattern_list patterns;
Rule* next; // Linkage within RuleHdrTest tree: Rule* next; // Linkage within RuleHdrTest tree:

View file

@ -57,9 +57,9 @@ struct MaskedValue {
uint32_t mask; uint32_t mask;
}; };
typedef PList<MaskedValue> maskedvalue_list; using maskedvalue_list = zeek::PList<MaskedValue>;
typedef PList<char> string_list; using string_list = zeek::PList<char>;
typedef PList<BroString> bstr_list; using bstr_list = zeek::PList<BroString>;
// Get values from Bro's script-level variables. // Get values from Bro's script-level variables.
extern void id_to_maskedvallist(const char* id, maskedvalue_list* append_to, extern void id_to_maskedvallist(const char* id, maskedvalue_list* append_to,
@ -117,7 +117,7 @@ private:
int_list ids; // (only needed for debugging) int_list ids; // (only needed for debugging)
}; };
typedef PList<PatternSet> pattern_set_list; using pattern_set_list = zeek::PList<PatternSet>;
pattern_set_list psets[Rule::TYPES]; pattern_set_list psets[Rule::TYPES];
// List of rules belonging to this node. // List of rules belonging to this node.
@ -131,7 +131,7 @@ private:
RuleHdrTest* child; RuleHdrTest* child;
}; };
typedef PList<RuleHdrTest> rule_hdr_test_list; using rule_hdr_test_list = zeek::PList<RuleHdrTest>;
// RuleEndpointState keeps the per-stream matching state of one // RuleEndpointState keeps the per-stream matching state of one
// connection endpoint. // connection endpoint.
@ -166,7 +166,7 @@ private:
Rule::PatternType type; Rule::PatternType type;
}; };
typedef PList<Matcher> matcher_list; using matcher_list = zeek::PList<Matcher>;
analyzer::Analyzer* analyzer; analyzer::Analyzer* analyzer;
RuleEndpointState* opposite; RuleEndpointState* opposite;
@ -205,8 +205,7 @@ private:
RE_Match_State* state; RE_Match_State* state;
}; };
typedef PList<Matcher> matcher_list; using matcher_list = zeek::PList<Matcher>;
matcher_list matchers; matcher_list matchers;
}; };

View file

@ -12,7 +12,7 @@
namespace zeek::detail { namespace zeek::detail {
using scope_list = PList<Scope>; using scope_list = zeek::PList<Scope>;
static scope_list scopes; static scope_list scopes;
static Scope* top_scope; static Scope* top_scope;

View file

@ -190,7 +190,7 @@ protected:
StmtPtr s; StmtPtr s;
}; };
using case_list = PList<Case>; using case_list = zeek::PList<Case>;
class SwitchStmt final : public ExprStmt { class SwitchStmt final : public ExprStmt {
public: public:
@ -229,7 +229,7 @@ protected:
case_list* cases; case_list* cases;
int default_case_idx; int default_case_idx;
CompositeHash* comp_hash; CompositeHash* comp_hash;
PDict<int> case_label_value_map; zeek::PDict<int> case_label_value_map;
std::vector<std::pair<ID*, int>> case_label_type_list; std::vector<std::pair<ID*, int>> case_label_type_list;
}; };

View file

@ -620,7 +620,7 @@ public:
const char* id = nullptr; const char* id = nullptr;
}; };
using type_decl_list = PList<TypeDecl>; using type_decl_list = zeek::PList<TypeDecl>;
class RecordType final : public Type { class RecordType final : public Type {
public: public:

View file

@ -25,9 +25,12 @@
#define UDP_PORT_MASK 0x20000 #define UDP_PORT_MASK 0x20000
#define ICMP_PORT_MASK 0x30000 #define ICMP_PORT_MASK 0x30000
namespace zeek {
template<typename T> class PDict; template<typename T> class PDict;
};
template<typename T> using PDict [[deprecated("Remove in v4.1. Use zeek::PDict instead.")]] = zeek::PDict<T>;
class IterCookie; ZEEK_FORWARD_DECLARE_NAMESPACED(IterCookie, zeek);
class BroString; class BroString;
class BroFile; class BroFile;
@ -99,7 +102,7 @@ union BroValUnion {
zeek::detail::Func* func_val; zeek::detail::Func* func_val;
BroFile* file_val; BroFile* file_val;
RE_Matcher* re_val; RE_Matcher* re_val;
PDict<TableEntryVal>* table_val; zeek::PDict<TableEntryVal>* table_val;
std::vector<ValPtr>* record_val; std::vector<ValPtr>* record_val;
std::vector<ValPtr>* vector_val; std::vector<ValPtr>* vector_val;
@ -132,7 +135,7 @@ union BroValUnion {
constexpr BroValUnion(RE_Matcher* value) noexcept constexpr BroValUnion(RE_Matcher* value) noexcept
: re_val(value) {} : re_val(value) {}
constexpr BroValUnion(PDict<TableEntryVal>* value) noexcept constexpr BroValUnion(zeek::PDict<TableEntryVal>* value) noexcept
: table_val(value) {} : table_val(value) {}
}; };
@ -237,7 +240,7 @@ public:
CONST_ACCESSOR2(zeek::TYPE_ENUM, int, int_val, AsEnum) CONST_ACCESSOR2(zeek::TYPE_ENUM, int, int_val, AsEnum)
CONST_ACCESSOR(zeek::TYPE_STRING, BroString*, string_val, AsString) CONST_ACCESSOR(zeek::TYPE_STRING, BroString*, string_val, AsString)
CONST_ACCESSOR(zeek::TYPE_FUNC, zeek::detail::Func*, func_val, AsFunc) CONST_ACCESSOR(zeek::TYPE_FUNC, zeek::detail::Func*, func_val, AsFunc)
CONST_ACCESSOR(zeek::TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsTable) CONST_ACCESSOR(zeek::TYPE_TABLE, zeek::PDict<TableEntryVal>*, table_val, AsTable)
CONST_ACCESSOR(zeek::TYPE_RECORD, std::vector<ValPtr>*, record_val, AsRecord) CONST_ACCESSOR(zeek::TYPE_RECORD, std::vector<ValPtr>*, record_val, AsRecord)
CONST_ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile) CONST_ACCESSOR(zeek::TYPE_FILE, BroFile*, file_val, AsFile)
CONST_ACCESSOR(zeek::TYPE_PATTERN, RE_Matcher*, re_val, AsPattern) CONST_ACCESSOR(zeek::TYPE_PATTERN, RE_Matcher*, re_val, AsPattern)
@ -385,7 +388,7 @@ protected:
: type(std::move(t)) : type(std::move(t))
{} {}
ACCESSOR(zeek::TYPE_TABLE, PDict<TableEntryVal>*, table_val, AsNonConstTable) ACCESSOR(zeek::TYPE_TABLE, zeek::PDict<TableEntryVal>*, table_val, AsNonConstTable)
ACCESSOR(zeek::TYPE_RECORD, std::vector<ValPtr>*, record_val, AsNonConstRecord) ACCESSOR(zeek::TYPE_RECORD, std::vector<ValPtr>*, record_val, AsNonConstRecord)
// For internal use by the Val::Clone() methods. // For internal use by the Val::Clone() methods.

View file

@ -70,14 +70,14 @@ protected:
class SteppingStoneManager { class SteppingStoneManager {
public: public:
PQueue<SteppingStoneEndpoint>& OrderedEndpoints() zeek::PQueue<SteppingStoneEndpoint>& OrderedEndpoints()
{ return ordered_endps; } { return ordered_endps; }
// Use postfix ++, since the first ID needs to be even. // Use postfix ++, since the first ID needs to be even.
int NextID() { return endp_cnt++; } int NextID() { return endp_cnt++; }
protected: protected:
PQueue<SteppingStoneEndpoint> ordered_endps; zeek::PQueue<SteppingStoneEndpoint> ordered_endps;
int endp_cnt = 0; int endp_cnt = 0;
}; };

View file

@ -28,12 +28,12 @@ std::set<std::string> val_to_topic_set(zeek::Val* val)
rval.emplace(val->AsString()->CheckString()); rval.emplace(val->AsString()->CheckString());
else else
{ {
const PDict<zeek::TableEntryVal>* tbl = val->AsTable(); const zeek::PDict<zeek::TableEntryVal>* tbl = val->AsTable();
if ( tbl->Length() == 0 ) if ( tbl->Length() == 0 )
return rval; return rval;
IterCookie* c = tbl->InitForIteration(); zeek::IterCookie* c = tbl->InitForIteration();
HashKey* k; HashKey* k;
while ( tbl->NextEntry(k, c) ) while ( tbl->NextEntry(k, c) )

View file

@ -93,7 +93,7 @@ public:
* @see Dictionary#InitForIteration * @see Dictionary#InitForIteration
* @return an iterator that may be used to loop over analyzers in the set. * @return an iterator that may be used to loop over analyzers in the set.
*/ */
IterCookie* InitForIteration() const zeek::IterCookie* InitForIteration() const
{ return analyzer_map.InitForIteration(); } { return analyzer_map.InitForIteration(); }
/** /**
@ -103,7 +103,7 @@ public:
* @return the next analyzer in the set or a null pointer if there is no * @return the next analyzer in the set or a null pointer if there is no
* more left (in that case the cookie is also deleted). * more left (in that case the cookie is also deleted).
*/ */
file_analysis::Analyzer* NextEntry(IterCookie* c) file_analysis::Analyzer* NextEntry(zeek::IterCookie* c)
{ return analyzer_map.NextEntry(c); } { return analyzer_map.NextEntry(c); }
protected: protected:
@ -145,7 +145,7 @@ private:
File* file; /**< File which owns the set */ File* file; /**< File which owns the set */
CompositeHash* analyzer_hash; /**< AnalyzerArgs hashes. */ CompositeHash* analyzer_hash; /**< AnalyzerArgs hashes. */
PDict<file_analysis::Analyzer> analyzer_map; /**< Indexed by AnalyzerArgs. */ zeek::PDict<file_analysis::Analyzer> analyzer_map; /**< Indexed by AnalyzerArgs. */
/** /**
* Abstract base class for analyzer set modifications. * Abstract base class for analyzer set modifications.

View file

@ -394,7 +394,7 @@ void File::DeliverStream(const u_char* data, uint64_t len)
len > 40 ? "..." : ""); len > 40 ? "..." : "");
file_analysis::Analyzer* a = nullptr; file_analysis::Analyzer* a = nullptr;
IterCookie* c = analyzers.InitForIteration(); zeek::IterCookie* c = analyzers.InitForIteration();
while ( (a = analyzers.NextEntry(c)) ) while ( (a = analyzers.NextEntry(c)) )
{ {
@ -498,7 +498,7 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset)
len > 40 ? "..." : ""); len > 40 ? "..." : "");
file_analysis::Analyzer* a = nullptr; file_analysis::Analyzer* a = nullptr;
IterCookie* c = analyzers.InitForIteration(); zeek::IterCookie* c = analyzers.InitForIteration();
while ( (a = analyzers.NextEntry(c)) ) while ( (a = analyzers.NextEntry(c)) )
{ {
@ -562,7 +562,7 @@ void File::EndOfFile()
done = true; done = true;
file_analysis::Analyzer* a = nullptr; file_analysis::Analyzer* a = nullptr;
IterCookie* c = analyzers.InitForIteration(); zeek::IterCookie* c = analyzers.InitForIteration();
while ( (a = analyzers.NextEntry(c)) ) while ( (a = analyzers.NextEntry(c)) )
{ {
@ -595,7 +595,7 @@ void File::Gap(uint64_t offset, uint64_t len)
} }
file_analysis::Analyzer* a = nullptr; file_analysis::Analyzer* a = nullptr;
IterCookie* c = analyzers.InitForIteration(); zeek::IterCookie* c = analyzers.InitForIteration();
while ( (a = analyzers.NextEntry(c)) ) while ( (a = analyzers.NextEntry(c)) )
{ {

View file

@ -18,7 +18,7 @@ extern void add_input_file_at_front(const char* file);
// Adds the substrings (using the given delimiter) in a string to the // Adds the substrings (using the given delimiter) in a string to the
// given namelist. // given namelist.
extern void add_to_name_list(char* s, char delim, name_list& nl); extern void add_to_name_list(char* s, char delim, zeek::name_list& nl);
extern void begin_RE(); extern void begin_RE();

View file

@ -99,8 +99,8 @@ public:
zeek::RecordType* rtype; zeek::RecordType* rtype;
zeek::RecordType* itype; zeek::RecordType* itype;
PDict<InputHash>* currDict; zeek::PDict<InputHash>* currDict;
PDict<InputHash>* lastDict; zeek::PDict<InputHash>* lastDict;
zeek::detail::Func* pred; zeek::detail::Func* pred;
@ -273,7 +273,7 @@ bool Manager::CreateStream(Stream* info, zeek::RecordVal* description)
{ {
// create config mapping in ReaderInfo. Has to be done before the construction of reader_obj. // create config mapping in ReaderInfo. Has to be done before the construction of reader_obj.
HashKey* k; HashKey* k;
IterCookie* c = info->config->AsTable()->InitForIteration(); zeek::IterCookie* c = info->config->AsTable()->InitForIteration();
zeek::TableEntryVal* v; zeek::TableEntryVal* v;
while ( (v = info->config->AsTable()->NextEntry(k, c)) ) while ( (v = info->config->AsTable()->NextEntry(k, c)) )
@ -674,9 +674,9 @@ bool Manager::CreateTableStream(zeek::RecordVal* fval)
stream->itype = idx->Ref()->AsRecordType(); stream->itype = idx->Ref()->AsRecordType();
stream->event = event ? event_registry->Lookup(event->Name()) : nullptr; stream->event = event ? event_registry->Lookup(event->Name()) : nullptr;
stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr; stream->error_event = error_event ? event_registry->Lookup(error_event->Name()) : nullptr;
stream->currDict = new PDict<InputHash>; stream->currDict = new zeek::PDict<InputHash>;
stream->currDict->SetDeleteFunc(input_hash_delete_func); stream->currDict->SetDeleteFunc(input_hash_delete_func);
stream->lastDict = new PDict<InputHash>; stream->lastDict = new zeek::PDict<InputHash>;
stream->lastDict->SetDeleteFunc(input_hash_delete_func); stream->lastDict->SetDeleteFunc(input_hash_delete_func);
stream->want_record = ( want_record->InternalInt() == 1 ); stream->want_record = ( want_record->InternalInt() == 1 );
@ -1319,7 +1319,7 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
TableStream* stream = (TableStream*) i; TableStream* stream = (TableStream*) i;
// lastdict contains all deleted entries and should be empty apart from that // lastdict contains all deleted entries and should be empty apart from that
IterCookie *c = stream->lastDict->InitForIteration(); zeek::IterCookie *c = stream->lastDict->InitForIteration();
stream->lastDict->MakeRobustCookie(c); stream->lastDict->MakeRobustCookie(c);
InputHash* ih; InputHash* ih;
HashKey *lastDictIdxKey; HashKey *lastDictIdxKey;
@ -1372,7 +1372,7 @@ void Manager::EndCurrentSend(ReaderFrontend* reader)
delete(stream->lastDict); delete(stream->lastDict);
stream->lastDict = stream->currDict; stream->lastDict = stream->currDict;
stream->currDict = new PDict<InputHash>; stream->currDict = new zeek::PDict<InputHash>;
stream->currDict->SetDeleteFunc(input_hash_delete_func); stream->currDict->SetDeleteFunc(input_hash_delete_func);
#ifdef DEBUG #ifdef DEBUG

View file

@ -859,7 +859,7 @@ bool Manager::Write(zeek::EnumVal* id, zeek::RecordVal* columns_arg)
info->network_time = network_time; info->network_time = network_time;
HashKey* k; HashKey* k;
IterCookie* c = filter->config->AsTable()->InitForIteration(); zeek::IterCookie* c = filter->config->AsTable()->InitForIteration();
zeek::TableEntryVal* v; zeek::TableEntryVal* v;
while ( (v = filter->config->AsTable()->NextEntry(k, c)) ) while ( (v = filter->config->AsTable()->NextEntry(k, c)) )

View file

@ -35,7 +35,7 @@ HashKey* TopkVal::GetHash(Val* v) const
TopkVal::TopkVal(uint64_t arg_size) : OpaqueVal(topk_type) TopkVal::TopkVal(uint64_t arg_size) : OpaqueVal(topk_type)
{ {
elementDict = new PDict<Element>; elementDict = new zeek::PDict<Element>;
elementDict->SetDeleteFunc(topk_element_hash_delete_func); elementDict->SetDeleteFunc(topk_element_hash_delete_func);
size = arg_size; size = arg_size;
numElements = 0; numElements = 0;
@ -45,7 +45,7 @@ TopkVal::TopkVal(uint64_t arg_size) : OpaqueVal(topk_type)
TopkVal::TopkVal() : OpaqueVal(topk_type) TopkVal::TopkVal() : OpaqueVal(topk_type)
{ {
elementDict = new PDict<Element>; elementDict = new zeek::PDict<Element>;
elementDict->SetDeleteFunc(topk_element_hash_delete_func); elementDict->SetDeleteFunc(topk_element_hash_delete_func);
size = 0; size = 0;
numElements = 0; numElements = 0;

View file

@ -166,7 +166,7 @@ private:
zeek::TypePtr type; zeek::TypePtr type;
CompositeHash* hash; CompositeHash* hash;
std::list<Bucket*> buckets; std::list<Bucket*> buckets;
PDict<Element>* elementDict; zeek::PDict<Element>* elementDict;
uint64_t size; // how many elements are we tracking? uint64_t size; // how many elements are we tracking?
uint64_t numElements; // how many elements do we have at the moment uint64_t numElements; // how many elements do we have at the moment
bool pruned; // was this data structure pruned? bool pruned; // was this data structure pruned?

View file

@ -139,7 +139,7 @@ public:
// A stack of input buffers we're scanning. file_stack[len-1] is the // A stack of input buffers we're scanning. file_stack[len-1] is the
// top of the stack. // top of the stack.
static PList<FileInfo> file_stack; static zeek::PList<FileInfo> file_stack;
#define RET_CONST(v) \ #define RET_CONST(v) \
{ \ { \
@ -835,8 +835,8 @@ void do_atendif()
// Be careful to never delete things from this list, as the strings // Be careful to never delete things from this list, as the strings
// are referred to (in order to save the locations of tokens and statements, // are referred to (in order to save the locations of tokens and statements,
// for error reporting and debugging). // for error reporting and debugging).
static name_list input_files; static zeek::name_list input_files;
static name_list essential_input_files; static zeek::name_list essential_input_files;
void add_essential_input_file(const char* file) void add_essential_input_file(const char* file)
{ {
@ -871,7 +871,7 @@ void add_input_file_at_front(const char* file)
input_files.push_front(copy_string(file)); input_files.push_front(copy_string(file));
} }
void add_to_name_list(char* s, char delim, name_list& nl) void add_to_name_list(char* s, char delim, zeek::name_list& nl)
{ {
while ( s ) while ( s )
{ {
@ -917,7 +917,7 @@ int yywrap()
// Stack is now empty. // Stack is now empty.
while ( essential_input_files.length() > 0 || input_files.length() > 0 ) while ( essential_input_files.length() > 0 || input_files.length() > 0 )
{ {
name_list& files = essential_input_files.length() > 0 ? zeek::name_list& files = essential_input_files.length() > 0 ?
essential_input_files : input_files; essential_input_files : input_files;
if ( load_files(files[0]) ) if ( load_files(files[0]) )