From 3f84324d6ccedca6872ca944b63ebdbd4f9c5759 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Sun, 23 Apr 2000 04:42:01 +0200 Subject: [PATCH] Added a PTR_HASH_LOOP() macro. Rev: src/block_alloc.h:1.20 Rev: src/block_alloc_h.h:1.7 Rev: src/las.h:1.34 --- src/block_alloc.h | 9 +++------ src/block_alloc_h.h | 7 +++++++ src/las.h | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/block_alloc.h b/src/block_alloc.h index 8d304bbd31..3e99bdfdf2 100644 --- a/src/block_alloc.h +++ b/src/block_alloc.h @@ -1,4 +1,4 @@ -/* $Id: block_alloc.h,v 1.19 2000/04/17 21:06:24 hubbe Exp $ */ +/* $Id: block_alloc.h,v 1.20 2000/04/23 02:42:01 mast Exp $ */ #undef PRE_INIT_BLOCK #undef INIT_BLOCK #undef EXIT_BLOCK @@ -112,8 +112,8 @@ void PIKE_CONCAT3(count_memory_in_,DATA,s)(INT32 *num_, INT32 *size_) \ \ BLOCK_ALLOC(DATA,BSIZE) \ \ -static struct DATA **PIKE_CONCAT(DATA,_hash_table)=0; \ -static int PIKE_CONCAT(DATA,_hash_table_size)=0; \ +struct DATA **PIKE_CONCAT(DATA,_hash_table)=0; \ +int PIKE_CONCAT(DATA,_hash_table_size)=0; \ static int PIKE_CONCAT(num_,DATA)=0; \ \ inline struct DATA * \ @@ -267,6 +267,3 @@ void PIKE_CONCAT3(exit_,DATA,_hash)(void) \ PIKE_CONCAT(DATA,_hash_table)=0; \ PIKE_CONCAT(num_,DATA)=0; \ } - -#define BLOCK_ALLOC_NEXT next - diff --git a/src/block_alloc_h.h b/src/block_alloc_h.h index 49a45ab6ba..238787a8fa 100644 --- a/src/block_alloc_h.h +++ b/src/block_alloc_h.h @@ -10,6 +10,8 @@ void PIKE_CONCAT3(count_memory_in_,DATA,s)(INT32 *num, INT32 *size); \ #define PTR_HASH_ALLOC(DATA,BSIZE) \ BLOCK_ALLOC(DATA,BSIZE) \ +extern struct DATA **PIKE_CONCAT(DATA,_hash_table); \ +extern int PIKE_CONCAT(DATA,_hash_table_size); \ struct DATA *PIKE_CONCAT(find_,DATA)(void *ptr); \ struct DATA *PIKE_CONCAT(get_,DATA)(void *ptr); \ int PIKE_CONCAT3(check_,DATA,_semafore)(void *ptr); \ @@ -17,4 +19,9 @@ int PIKE_CONCAT(remove_,DATA)(void *ptr); \ void PIKE_CONCAT3(init_,DATA,_hash)(void); \ void PIKE_CONCAT3(exit_,DATA,_hash)(void); \ +#define PTR_HASH_LOOP(DATA,HVAL,PTR) \ + for ((HVAL) = PIKE_CONCAT(DATA,_hash_table_size); (HVAL)-- > 0;) \ + for ((PTR) = PIKE_CONCAT(DATA,_hash_table)[HVAL]; \ + (PTR); (PTR) = (PTR)->BLOCK_ALLOC_NEXT) +#define BLOCK_ALLOC_NEXT next diff --git a/src/las.h b/src/las.h index 00723dfdaa..b1f71a3673 100644 --- a/src/las.h +++ b/src/las.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: las.h,v 1.33 1999/12/29 17:54:03 grubba Exp $ + * $Id: las.h,v 1.34 2000/04/23 02:42:01 mast Exp $ */ #ifndef LAS_H #define LAS_H @@ -15,6 +15,7 @@ #include "svalue.h" #include "dynamic_buffer.h" #include "program.h" +#include "block_alloc_h.h" #define MAX_GLOBAL_VARIABLES 1000 typedef void (*c_fun)(INT32); -- GitLab