plugin/probabilistic/zeekygen: Replace nulls with nullptr

This commit is contained in:
Tim Wojtulewicz 2020-04-02 10:39:28 -07:00
parent 393b8353cb
commit 41c3256faa
10 changed files with 36 additions and 36 deletions

View file

@ -134,7 +134,7 @@ ComponentManager<T, C>::ComponentManager(const string& arg_module, const string&
tag_enum_type(make_intrusive<EnumType>(module + "::" + local_id)) tag_enum_type(make_intrusive<EnumType>(module + "::" + local_id))
{ {
auto id = install_ID(local_id.c_str(), module.c_str(), true, true); auto id = install_ID(local_id.c_str(), module.c_str(), true, true);
add_type(id.get(), tag_enum_type, 0); add_type(id.get(), tag_enum_type, nullptr);
zeekygen_mgr->Identifier(std::move(id)); zeekygen_mgr->Identifier(std::move(id));
} }

View file

@ -19,9 +19,9 @@
using namespace plugin; using namespace plugin;
Plugin* Manager::current_plugin = 0; Plugin* Manager::current_plugin = nullptr;
const char* Manager::current_dir = 0; const char* Manager::current_dir = nullptr;
const char* Manager::current_sopath = 0; const char* Manager::current_sopath = nullptr;
Manager::Manager() Manager::Manager()
{ {
@ -29,7 +29,7 @@ Manager::Manager()
hooks = new hook_list*[NUM_HOOKS]; hooks = new hook_list*[NUM_HOOKS];
for ( int i = 0; i < NUM_HOOKS; i++ ) for ( int i = 0; i < NUM_HOOKS; i++ )
hooks[i] = 0; hooks[i] = nullptr;
} }
Manager::~Manager() Manager::~Manager()
@ -238,7 +238,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
{ {
const char* path = gl.gl_pathv[i]; const char* path = gl.gl_pathv[i];
current_plugin = 0; current_plugin = nullptr;
current_dir = dir.c_str(); current_dir = dir.c_str();
current_sopath = path; current_sopath = path;
void* hdl = dlopen(path, RTLD_LAZY | RTLD_GLOBAL); void* hdl = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
@ -270,9 +270,9 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
reporter->FatalError("inconsistent plugin name: %s vs %s", reporter->FatalError("inconsistent plugin name: %s vs %s",
current_plugin->Name().c_str(), name.c_str()); current_plugin->Name().c_str(), name.c_str());
current_dir = 0; current_dir = nullptr;
current_sopath = 0; current_sopath = nullptr;
current_plugin = 0; current_plugin = nullptr;
DBG_LOG(DBG_PLUGINS, " Loaded %s", path); DBG_LOG(DBG_PLUGINS, " Loaded %s", path);
} }
@ -461,7 +461,7 @@ Manager::inactive_plugin_list Manager::InactivePlugins() const
Manager::plugin_list* Manager::ActivePluginsInternal() Manager::plugin_list* Manager::ActivePluginsInternal()
{ {
static plugin_list* plugins = 0; static plugin_list* plugins = nullptr;
if ( ! plugins ) if ( ! plugins )
plugins = new plugin_list; plugins = new plugin_list;
@ -471,7 +471,7 @@ Manager::plugin_list* Manager::ActivePluginsInternal()
Manager::bif_init_func_map* Manager::BifFilesInternal() Manager::bif_init_func_map* Manager::BifFilesInternal()
{ {
static bif_init_func_map* bifs = 0; static bif_init_func_map* bifs = nullptr;
if ( ! bifs ) if ( ! bifs )
bifs = new bif_init_func_map; bifs = new bif_init_func_map;
@ -571,7 +571,7 @@ void Manager::DisableHook(HookType hook, Plugin* plugin)
if ( l->empty() ) if ( l->empty() )
{ {
delete l; delete l;
hooks[hook] = 0; hooks[hook] = nullptr;
} }
} }

View file

@ -168,7 +168,7 @@ public:
bool HavePluginForHook(HookType hook) const bool HavePluginForHook(HookType hook) const
{ {
// Inline to avoid the function call. // Inline to avoid the function call.
return hooks[hook] != 0; return hooks[hook] != nullptr;
} }
/** /**

View file

@ -475,7 +475,7 @@ void Plugin::Describe(ODesc* d) const
for ( bif_item_list::const_iterator i = items.begin(); i != items.end(); i++ ) for ( bif_item_list::const_iterator i = items.begin(); i != items.end(); i++ )
{ {
const char* type = 0; const char* type = nullptr;
switch ( (*i).GetType() ) { switch ( (*i).GetType() ) {
case BifItem::FUNCTION: case BifItem::FUNCTION:

View file

@ -17,7 +17,7 @@ using namespace probabilistic;
BloomFilter::BloomFilter() BloomFilter::BloomFilter()
{ {
hasher = 0; hasher = nullptr;
} }
BloomFilter::BloomFilter(const Hasher* arg_hasher) BloomFilter::BloomFilter(const Hasher* arg_hasher)
@ -142,7 +142,7 @@ std::string BasicBloomFilter::InternalState() const
BasicBloomFilter::BasicBloomFilter() BasicBloomFilter::BasicBloomFilter()
{ {
bits = 0; bits = nullptr;
} }
BasicBloomFilter::BasicBloomFilter(const Hasher* hasher, size_t cells) BasicBloomFilter::BasicBloomFilter(const Hasher* hasher, size_t cells)
@ -195,7 +195,7 @@ bool BasicBloomFilter::DoUnserialize(const broker::data& data)
CountingBloomFilter::CountingBloomFilter() CountingBloomFilter::CountingBloomFilter()
{ {
cells = 0; cells = nullptr;
} }
CountingBloomFilter::CountingBloomFilter(const Hasher* hasher, CountingBloomFilter::CountingBloomFilter(const Hasher* hasher,

View file

@ -44,10 +44,10 @@ TopkVal::TopkVal(uint64_t arg_size) : OpaqueVal(topk_type)
elementDict = new PDict<Element>; elementDict = new PDict<Element>;
elementDict->SetDeleteFunc(topk_element_hash_delete_func); elementDict->SetDeleteFunc(topk_element_hash_delete_func);
size = arg_size; size = arg_size;
type = 0; type = nullptr;
numElements = 0; numElements = 0;
pruned = false; pruned = false;
hash = 0; hash = nullptr;
} }
TopkVal::TopkVal() : OpaqueVal(topk_type) TopkVal::TopkVal() : OpaqueVal(topk_type)
@ -55,9 +55,9 @@ TopkVal::TopkVal() : OpaqueVal(topk_type)
elementDict = new PDict<Element>; elementDict = new PDict<Element>;
elementDict->SetDeleteFunc(topk_element_hash_delete_func); elementDict->SetDeleteFunc(topk_element_hash_delete_func);
size = 0; size = 0;
type = 0; type = nullptr;
numElements = 0; numElements = 0;
hash = 0; hash = nullptr;
} }
TopkVal::~TopkVal() TopkVal::~TopkVal()
@ -86,7 +86,7 @@ void TopkVal::Merge(const TopkVal* value, bool doPrune)
return; return;
} }
if ( type == 0 ) if ( type == nullptr )
{ {
assert(numElements == 0); assert(numElements == 0);
Typify(value->type); Typify(value->type);
@ -115,7 +115,7 @@ void TopkVal::Merge(const TopkVal* value, bool doPrune)
HashKey* key = GetHash(e->value); HashKey* key = GetHash(e->value);
Element* olde = (Element*) elementDict->Lookup(key); Element* olde = (Element*) elementDict->Lookup(key);
if ( olde == 0 ) if ( olde == nullptr )
{ {
olde = new Element(); olde = new Element();
olde->epsilon = 0; olde->epsilon = 0;
@ -196,7 +196,7 @@ VectorVal* TopkVal::GetTopK(int k) const // returns vector
if ( numElements == 0 ) if ( numElements == 0 )
{ {
reporter->Error("Cannot return topk of empty"); reporter->Error("Cannot return topk of empty");
return 0; return nullptr;
} }
auto vector_index = make_intrusive<TypeList>(IntrusivePtr{NewRef{}, type}); auto vector_index = make_intrusive<TypeList>(IntrusivePtr{NewRef{}, type});
@ -238,7 +238,7 @@ uint64_t TopkVal::GetCount(Val* value) const
Element* e = (Element*) elementDict->Lookup(key); Element* e = (Element*) elementDict->Lookup(key);
delete key; delete key;
if ( e == 0 ) if ( e == nullptr )
{ {
reporter->Error("GetCount for element that is not in top-k"); reporter->Error("GetCount for element that is not in top-k");
return 0; return 0;
@ -253,7 +253,7 @@ uint64_t TopkVal::GetEpsilon(Val* value) const
Element* e = (Element*) elementDict->Lookup(key); Element* e = (Element*) elementDict->Lookup(key);
delete key; delete key;
if ( e == 0 ) if ( e == nullptr )
{ {
reporter->Error("GetEpsilon for element that is not in top-k"); reporter->Error("GetEpsilon for element that is not in top-k");
return 0; return 0;
@ -297,7 +297,7 @@ void TopkVal::Encountered(Val* encountered)
HashKey* key = GetHash(encountered); HashKey* key = GetHash(encountered);
Element* e = (Element*) elementDict->Lookup(key); Element* e = (Element*) elementDict->Lookup(key);
if ( e == 0 ) if ( e == nullptr )
{ {
e = new Element(); e = new Element();
e->epsilon = 0; e->epsilon = 0;
@ -370,7 +370,7 @@ void TopkVal::IncrementCounter(Element* e, unsigned int count)
// well, let's test if there is a bucket for currcount++ // well, let's test if there is a bucket for currcount++
std::list<Bucket*>::iterator bucketIter = currBucket->bucketPos; std::list<Bucket*>::iterator bucketIter = currBucket->bucketPos;
Bucket* nextBucket = 0; Bucket* nextBucket = nullptr;
bucketIter++; bucketIter++;
@ -380,7 +380,7 @@ void TopkVal::IncrementCounter(Element* e, unsigned int count)
if ( bucketIter != buckets.end() && (*bucketIter)->count == currcount+count ) if ( bucketIter != buckets.end() && (*bucketIter)->count == currcount+count )
nextBucket = *bucketIter; nextBucket = *bucketIter;
if ( nextBucket == 0 ) if ( nextBucket == nullptr )
{ {
// the bucket for the value that we want does not exist. // the bucket for the value that we want does not exist.
// create it... // create it...
@ -405,7 +405,7 @@ void TopkVal::IncrementCounter(Element* e, unsigned int count)
{ {
buckets.remove(currBucket); buckets.remove(currBucket);
delete currBucket; delete currBucket;
currBucket = 0; currBucket = nullptr;
} }
} }
@ -519,7 +519,7 @@ bool TopkVal::DoUnserialize(const broker::data& data)
b->elements.insert(b->elements.end(), e); b->elements.insert(b->elements.end(), e);
HashKey* key = GetHash(e->value); HashKey* key = GetHash(e->value);
assert (elementDict->Lookup(key) == 0); assert (elementDict->Lookup(key) == nullptr);
elementDict->Insert(key, e); elementDict->Insert(key, e);
delete key; delete key;

View file

@ -91,7 +91,7 @@ public:
* comments are correctly associated. * comments are correctly associated.
*/ */
void CompletedTypeDecl() void CompletedTypeDecl()
{ last_field_seen = 0; } { last_field_seen = nullptr; }
/** /**
* @return the script-level ID tracked by this info object. * @return the script-level ID tracked by this info object.

View file

@ -288,7 +288,7 @@ void Manager::Identifier(IntrusivePtr<ID> id)
{ {
DBG_LOG(DBG_ZEEKYGEN, "Finished document for type %s", id->Name()); DBG_LOG(DBG_ZEEKYGEN, "Finished document for type %s", id->Name());
incomplete_type->CompletedTypeDecl(); incomplete_type->CompletedTypeDecl();
incomplete_type = 0; incomplete_type = nullptr;
return; return;
} }
@ -318,7 +318,7 @@ void Manager::Identifier(IntrusivePtr<ID> id)
// Handled specially since they don't have a script location. // Handled specially since they don't have a script location.
DBG_LOG(DBG_ZEEKYGEN, "Made internal IdentifierInfo %s", DBG_LOG(DBG_ZEEKYGEN, "Made internal IdentifierInfo %s",
id->Name()); id->Name());
CreateIdentifierInfo(id, 0); CreateIdentifierInfo(id, nullptr);
return; return;
} }

View file

@ -438,7 +438,7 @@ vector<string> dir_contents_recursive(string dir)
char* dir_copy = copy_string(dir.c_str()); char* dir_copy = copy_string(dir.c_str());
char** scan_path = new char*[2]; char** scan_path = new char*[2];
scan_path[0] = dir_copy; scan_path[0] = dir_copy;
scan_path[1] = 0; scan_path[1] = NULL;
FTS* fts = fts_open(scan_path, FTS_NOCHDIR, 0); FTS* fts = fts_open(scan_path, FTS_NOCHDIR, 0);

View file

@ -148,7 +148,7 @@ public:
target_creator_map::const_iterator it = target_creators.find(type_name); target_creator_map::const_iterator it = target_creators.find(type_name);
if ( it == target_creators.end() ) if ( it == target_creators.end() )
return 0; return nullptr;
return it->second(name, pattern); return it->second(name, pattern);
} }