From: Willy Tarreau Date: Wed, 7 Sep 2022 09:20:01 +0000 (+0200) Subject: CLEANUP: activity: make memprof use the generic ptr_hash() function X-Git-Tag: v2.7-dev6~82 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=245d32fe8ff984ed2d5239216f558c1d6d5527f4;p=thirdparty%2Fhaproxy.git CLEANUP: activity: make memprof use the generic ptr_hash() function There's no need to keep a local version of that function anymore. --- diff --git a/src/activity.c b/src/activity.c index 627593d593..67c1017b72 100644 --- a/src/activity.c +++ b/src/activity.c @@ -62,21 +62,6 @@ struct memprof_stats memprof_stats[MEMPROF_HASH_BUCKETS + 1] = { }; /* used to detect recursive calls */ static THREAD_LOCAL int in_memprof = 0; -/* perform a pointer hash by scrambling its bits and retrieving the most - * mixed ones (topmost ones in 32-bit, middle ones in 64-bit). - */ -static unsigned int memprof_hash_ptr(const void *p) -{ - unsigned long long x = (unsigned long)p; - - x = 0xcbda9653U * x; - if (sizeof(long) == 4) - x >>= 32; - else - x >>= 33 - MEMPROF_HASH_BITS / 2; - return x & (MEMPROF_HASH_BUCKETS - 1); -} - /* These ones are used by glibc and will be called early. They are in charge of * initializing the handlers with the original functions. */ @@ -186,7 +171,7 @@ struct memprof_stats *memprof_get_bin(const void *ra, enum memprof_method meth) const void *old; unsigned int bin; - bin = memprof_hash_ptr(ra); + bin = ptr_hash(ra, MEMPROF_HASH_BITS); for (; memprof_stats[bin].caller != ra; bin = (bin + 1) & (MEMPROF_HASH_BUCKETS - 1)) { if (!--retries) { bin = MEMPROF_HASH_BUCKETS;