]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3988: host_cache: cppcheck fix
authorRaza Shafiq (rshafiq) <rshafiq@cisco.com>
Tue, 12 Sep 2023 13:45:49 +0000 (13:45 +0000)
committerSteven Baigal (sbaigal) <sbaigal@cisco.com>
Tue, 12 Sep 2023 13:45:49 +0000 (13:45 +0000)
Merge in SNORT/snort3 from ~RSHAFIQ/snort3:cppcheck_fix to master

Squashed commit of the following:

commit e031ab24740026fd43fdd062dfd830c389dc820d
Author: rshafiq <rshafiq@cisco.com>
Date:   Fri Sep 8 09:34:46 2023 -0400

    host_cache: cppcheck fix

src/host_tracker/test/cache_allocator_test.cc
src/host_tracker/test/host_cache_allocator_ht_test.cc

index c43adfd31bb8dabcabbfec44be586cb1e9da8a7a..7b6961410beae891c008183ef32663592494ac82 100644 (file)
@@ -46,7 +46,7 @@ void FatalError(const char* fmt, ...) { (void)fmt; exit(1); }
 }
 // Derive an allocator from CacheAlloc:
 template <class T>
-class Allocator : public CacheAlloc<T>
+class Alloc : public CacheAlloc<T>
 {
 public:
 
@@ -54,12 +54,12 @@ public:
     template <class U>
     struct rebind
     {
-        typedef Allocator<U> other;
+        typedef Alloc<U> other;
     };
 
     using CacheAlloc<T>::lru;
 
-    Allocator();
+    Alloc();
 };
 
 
@@ -68,7 +68,7 @@ class Item
 {
 public:
     typedef int ValueType;
-    vector<ValueType, Allocator<ValueType>> data;
+    vector<ValueType, Alloc<ValueType>> data;
 };
 
 // Instantiate a cache, as soon as we know the Item type:
@@ -78,7 +78,7 @@ CacheType cache(100);
 // Implement the allocator constructor AFTER we have a cache object
 // to point to and the implementation of our base CacheAlloc:
 template <class T>
-Allocator<T>::Allocator()
+Alloc<T>::Alloc()
 {
     lru = &cache;
 }
index 7bc9b5edb4ffd0b93beae14c118c79f4b59f236b..559793759bcc69d2e3e8114eda0d19ae6131c93c 100644 (file)
@@ -86,13 +86,13 @@ public:
 };
 
 typedef LruCacheSharedMemcap<string, Item, hash<string>> CacheType;
-CacheType cache(100);
+CacheType cache1(100);
 CacheType cache2(100);
 
 template <class T>
 Allocator<T>::Allocator()
 {
-    lru = &cache;
+    lru = &cache1;
 }
 
 
@@ -105,7 +105,7 @@ TEST(host_cache_allocator_ht, allocate_update)
 {   
     //declare a list with allocator cache
     std::list<string, Allocator<string>> test_list;
-    CHECK(test_list.get_allocator().get_lru() == &cache);
+    CHECK(test_list.get_allocator().get_lru() == &cache1);
     //update cache interface of test_list to cache_2
     update_allocator(test_list, &cache2);
     CHECK(test_list.get_allocator().get_lru() == &cache2);