Changeset 11

Show
Ignore:
Timestamp:
12/06/00 16:37:43 (14 years ago)
Author:
george
Message:

Updated hash function to use getrlimit/setrlimit.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/hash.c

    r7 r11  
    1717#include "hash.h" 
    1818 
     19extern int nr_open; 
    1920static int myprime[20] = { 
    2021        3,5,7,11,13,17,23,31,37,41,43,47,53,59,61,67,71,73,83,87 
     
    2425  int a, i; 
    2526  hash_element *elem; 
    26   a = hashpjw(hostheader,NR_OPEN); 
     27  a = hashpjw(hostheader,nr_open); 
    2728  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]; 
    3031    /* return -1 if element is not possibly in hsah*/ 
    3132    if (elem->fd == -1) 
     
    4041void inshash(hash_element b, hash_element *hash) { 
    4142  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; 
    4647      return; 
    4748    } 
  • trunk/hash.h

    r7 r11  
    11#ifndef _HASH_H_ 
    22#define _HASH_H_ 
    3  
    4 #include <linux/limits.h> 
    53 
    64typedef struct {