Skip to content
Snippets Groups Projects
Commit c2b2448c authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Added just_find_*() to PTR_HASH_ALLOC() et al.

This function performs the same duty as find_*(), but doesn't alter the hash-table.

Rev: src/block_alloc.h:1.65
parent 68aab555
No related branches found
No related tags found
Loading
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
|| This file is part of Pike. For copyright information see COPYRIGHT. || This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information. || for more information.
|| $Id: block_alloc.h,v 1.64 2003/03/15 16:18:32 grubba Exp $ || $Id: block_alloc.h,v 1.65 2003/03/16 19:17:07 grubba Exp $
*/ */
#undef PRE_INIT_BLOCK #undef PRE_INIT_BLOCK
...@@ -398,6 +398,39 @@ struct DATA *PIKE_CONCAT(find_,DATA)(void *ptr) \ ...@@ -398,6 +398,39 @@ struct DATA *PIKE_CONCAT(find_,DATA)(void *ptr) \
p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval); \ p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval); \
DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \ DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \
return p; \ return p; \
} \
\
static inline struct DATA * \
PIKE_CONCAT3(just_find_,DATA,_unlocked)(void *ptr, \
PIKE_HASH_T hval) \
{ \
struct DATA *p,**pp; \
p=PIKE_CONCAT(DATA,_hash_table)[hval]; \
if(!p || p->PTR_HASH_ALLOC_DATA == ptr) \
{ \
DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \
return p; \
} \
while((p=p->BLOCK_ALLOC_NEXT)) \
{ \
if(p->PTR_HASH_ALLOC_DATA==ptr) return p; \
} \
return 0; \
} \
\
static struct DATA *PIKE_CONCAT(just_find_,DATA)(void *ptr) \
{ \
struct DATA *p; \
PIKE_HASH_T hval = (PIKE_HASH_T)(((char *)ptr)-(char *)0); \
DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \
if(!PIKE_CONCAT(DATA,_hash_table_size)) { \
DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \
return 0; \
} \
hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \
p=PIKE_CONCAT3(just_find_,DATA,_unlocked)(ptr, hval); \
DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \
return p; \
} \ } \
\ \
\ \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment