]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2130 in SNORT/snort3 from ~MIALTIZE/snort3:template_viz to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 3 Apr 2020 20:05:50 +0000 (20:05 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Fri, 3 Apr 2020 20:05:50 +0000 (20:05 +0000)
Squashed commit of the following:

commit fc8fe9813154aff1cfa2891d1803681012a3f337
Author: Michael Altizer <mialtize@cisco.com>
Date:   Fri Apr 3 12:16:19 2020 -0400

    host_tracker: Move all HostCacheAlloc template implementions to the header

src/host_tracker/host_cache_allocator.cc
src/host_tracker/host_cache_allocator.h
src/host_tracker/test/host_cache_module_test.cc

index 69a9685b3ac0ecd6937984485a313b0b1ab5f395..564fc2b6e1f288a37f5b729b88d0e04cc334eb01 100644 (file)
 
 #include "host_cache.h"
 
-template <class T>
-T* HostCacheAlloc<T>::allocate(std::size_t n)
-{
-    size_t sz=n*sizeof(T);
-    T* out=std::allocator<T>::allocate(n);
-    lru->update(sz);
-    return out;
-}
-
-template <class T>
-void HostCacheAlloc<T>::deallocate(T* p, std::size_t n) noexcept
-{
-    size_t sz = n*sizeof(T);
-    std::allocator<T>::deallocate(p, n);
-    lru->update( -(int) sz);
-}
-
 template <class T>
 HostCacheAllocIp<T>::HostCacheAllocIp()
 {
index 0eb92916763f046f6ee0169d0110fc1e7ec98c88..756fa0da37265448577b2cb3905c10628193c82d 100644 (file)
@@ -44,6 +44,23 @@ protected:
     HostCacheInterface* lru = 0;
 };
 
+template <class T>
+T* HostCacheAlloc<T>::allocate(std::size_t n)
+{
+    size_t sz = n * sizeof(T);
+    T* out = std::allocator<T>::allocate(n);
+    lru->update(sz);
+    return out;
+}
+
+template <class T>
+void HostCacheAlloc<T>::deallocate(T* p, std::size_t n) noexcept
+{
+    size_t sz = n * sizeof(T);
+    std::allocator<T>::deallocate(p, n);
+    lru->update(-(int) sz);
+}
+
 
 // Trivial derived allocator, pointing to their own host cache.
 // HostCacheAllocIp has a HostCacheInterface* pointing to an lru cache
index 0db2a0b78cf6a6eafdb31a56e128322981474214..e048064c075328374c903607e1a09c6eb94824e7 100644 (file)
@@ -82,14 +82,6 @@ HostCacheAllocIp<T>::HostCacheAllocIp()
     lru = &host_cache;
 }
 
-template <class T>
-void HostCacheAlloc<T>::deallocate(T* p, std::size_t n) noexcept
-{
-    size_t sz = n*sizeof(T);
-    std::allocator<T>::deallocate(p, n);
-    lru->update( -(int) sz);
-}
-
 TEST_GROUP(host_cache_module)
 {
     void setup() override