From: Michael Altizer (mialtize) Date: Fri, 3 Apr 2020 20:05:50 +0000 (+0000) Subject: Merge pull request #2130 in SNORT/snort3 from ~MIALTIZE/snort3:template_viz to master X-Git-Tag: 3.0.1-2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c24df8c272ce9f7cc7e7bfa5be4b9bef4f8c260;p=thirdparty%2Fsnort3.git Merge pull request #2130 in SNORT/snort3 from ~MIALTIZE/snort3:template_viz to master Squashed commit of the following: commit fc8fe9813154aff1cfa2891d1803681012a3f337 Author: Michael Altizer Date: Fri Apr 3 12:16:19 2020 -0400 host_tracker: Move all HostCacheAlloc template implementions to the header --- diff --git a/src/host_tracker/host_cache_allocator.cc b/src/host_tracker/host_cache_allocator.cc index 69a9685b3..564fc2b6e 100644 --- a/src/host_tracker/host_cache_allocator.cc +++ b/src/host_tracker/host_cache_allocator.cc @@ -23,23 +23,6 @@ #include "host_cache.h" -template -T* HostCacheAlloc::allocate(std::size_t n) -{ - size_t sz=n*sizeof(T); - T* out=std::allocator::allocate(n); - lru->update(sz); - return out; -} - -template -void HostCacheAlloc::deallocate(T* p, std::size_t n) noexcept -{ - size_t sz = n*sizeof(T); - std::allocator::deallocate(p, n); - lru->update( -(int) sz); -} - template HostCacheAllocIp::HostCacheAllocIp() { diff --git a/src/host_tracker/host_cache_allocator.h b/src/host_tracker/host_cache_allocator.h index 0eb929167..756fa0da3 100644 --- a/src/host_tracker/host_cache_allocator.h +++ b/src/host_tracker/host_cache_allocator.h @@ -44,6 +44,23 @@ protected: HostCacheInterface* lru = 0; }; +template +T* HostCacheAlloc::allocate(std::size_t n) +{ + size_t sz = n * sizeof(T); + T* out = std::allocator::allocate(n); + lru->update(sz); + return out; +} + +template +void HostCacheAlloc::deallocate(T* p, std::size_t n) noexcept +{ + size_t sz = n * sizeof(T); + std::allocator::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 diff --git a/src/host_tracker/test/host_cache_module_test.cc b/src/host_tracker/test/host_cache_module_test.cc index 0db2a0b78..e048064c0 100644 --- a/src/host_tracker/test/host_cache_module_test.cc +++ b/src/host_tracker/test/host_cache_module_test.cc @@ -82,14 +82,6 @@ HostCacheAllocIp::HostCacheAllocIp() lru = &host_cache; } -template -void HostCacheAlloc::deallocate(T* p, std::size_t n) noexcept -{ - size_t sz = n*sizeof(T); - std::allocator::deallocate(p, n); - lru->update( -(int) sz); -} - TEST_GROUP(host_cache_module) { void setup() override