Changeset 11
- Timestamp:
- 12/06/00 16:37:43 (12 years ago)
- Files:
-
- trunk/hash.c (modified) (3 diffs)
- trunk/hash.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/hash.c
r7 r11 17 17 #include "hash.h" 18 18 19 extern int nr_open; 19 20 static int myprime[20] = { 20 21 3,5,7,11,13,17,23,31,37,41,43,47,53,59,61,67,71,73,83,87 … … 24 25 int a, i; 25 26 hash_element *elem; 26 a = hashpjw(hostheader, NR_OPEN);27 a = hashpjw(hostheader,nr_open); 27 28 if(hash[a].fd == -1) return -1; /* return -1 if element is not here */ 28 for(i=0;i< NR_OPEN; i++) {29 elem = &hash[(a+(i*myprime[a%20]))% NR_OPEN];29 for(i=0;i<nr_open; i++) { 30 elem = &hash[(a+(i*myprime[a%20]))%nr_open]; 30 31 /* return -1 if element is not possibly in hsah*/ 31 32 if (elem->fd == -1) … … 40 41 void inshash(hash_element b, hash_element *hash) { 41 42 int a, i; 42 a = hashpjw(b.hostheader, NR_OPEN);43 for(i=0;i< NR_OPEN; i++)44 if((hash[(a+(i*myprime[a%20]))% NR_OPEN].fd) == -1) {45 hash[(a+(i*myprime[a%20]))% NR_OPEN] = b;43 a = hashpjw(b.hostheader,nr_open); 44 for(i=0;i<nr_open; i++) 45 if((hash[(a+(i*myprime[a%20]))%nr_open].fd) == -1) { 46 hash[(a+(i*myprime[a%20]))%nr_open] = b; 46 47 return; 47 48 } trunk/hash.h
r7 r11 1 1 #ifndef _HASH_H_ 2 2 #define _HASH_H_ 3 4 #include <linux/limits.h>5 3 6 4 typedef struct {
