Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config-linuxmodule.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
/* Define to 1 if Linux defines the type 'uintptr_t'. */
#undef HAVE_UINTPTR_T_LINUXMODULE

/* Define to 1 to enable poisoning of freed HashAllocator blocks. */
#undef HAVE_HASH_ALLOCATOR_POISONING

/* The size of a `click_jiffies_t', as computed by sizeof. */
#define SIZEOF_CLICK_JIFFIES_T SIZEOF_LONG

Expand Down
3 changes: 3 additions & 0 deletions config-userlevel.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@
/* Define if you have the <valgrind/memcheck.h> header file. */
#undef HAVE_VALGRIND_MEMCHECK_H

/* Define to 1 to enable poisoning of freed HashAllocator blocks. */
#undef HAVE_HASH_ALLOCATOR_POISONING

/* Define if you have the vsnprintf function. */
#undef HAVE_VSNPRINTF

Expand Down
5 changes: 5 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,11 @@ if test "$value" != 0; then
AC_DEFINE_UNQUOTED([CLICK_DEBUG_SCHEDULING], [$value], [Define to enable debugging support for Click scheduling.])
fi

AC_ARG_ENABLE(hash-allocator-poisoning, [ --enable-hash-allocator-poisoning enable HashAllocator block poisoning], :, enable_hash_allocator_poisoning=no)
if test $enable_hash_allocator_poisoning = yes; then
AC_DEFINE(HAVE_HASH_ALLOCATOR_POISONING)
fi


dnl use Intel-specific machine instructions

Expand Down
8 changes: 8 additions & 0 deletions include/click/hashallocator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class HashAllocator { public:

private:

#if HAVE_HASH_ALLOCATOR_POISONING
// Freed blocks are poisoned with this byte value.
static const uint8_t poison_byte = 0x0d;
#endif

struct link {
link *next;
};
Expand Down Expand Up @@ -91,6 +96,9 @@ inline void *HashAllocator::allocate()
inline void HashAllocator::deallocate(void *p)
{
if (p) {
#if HAVE_HASH_ALLOCATOR_POISONING
memset(p, poison_byte, _size);
#endif
reinterpret_cast<link *>(p)->next = _free;
_free = reinterpret_cast<link *>(p);
#ifdef VALGRIND_MEMPOOL_FREE
Expand Down