ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/hash.c
(Generate patch)

Comparing ircd-hybrid-8/src/hash.c (file contents):
Revision 1395 by michael, Sun Apr 1 16:25:50 2012 UTC vs.
Revision 1396 by michael, Sun May 6 09:52:27 2012 UTC

# Line 45 | Line 45
45  
46   static BlockHeap *userhost_heap = NULL;
47   static BlockHeap *namehost_heap = NULL;
48 – static struct UserHost *find_or_add_userhost(const char *);
48  
49   static unsigned int hashf_xor_key = 0;
50  
# Line 607 | Line 606 | count_user_host(const char *user, const
606    }
607   }
608  
609 + /* find_or_add_userhost()
610 + *
611 + * inputs       - host name
612 + * output       - none
613 + * side effects - find UserHost * for given host name
614 + */
615 + static struct UserHost *
616 + find_or_add_userhost(const char *host)
617 + {
618 +  struct UserHost *userhost;
619 +
620 +  if ((userhost = hash_find_userhost(host)) != NULL)
621 +    return userhost;
622 +
623 +  userhost = BlockHeapAlloc(userhost_heap);
624 +  strlcpy(userhost->host, host, sizeof(userhost->host));
625 +  hash_add_userhost(userhost);
626 +
627 +  return userhost;
628 + }
629 +
630   /* add_user_host()
631   *
632   * inputs       - user name
# Line 639 | Line 659 | add_user_host(const char *user, const ch
659      if (!irccmp(user, nameh->name))
660      {
661        nameh->gcount++;
662 +
663        if (!global)
664        {
665 <        if (hasident)
666 <          nameh->icount++;
667 <        nameh->lcount++;
665 >        if (hasident)
666 >          nameh->icount++;
667 >        nameh->lcount++;
668        }
669 +
670        return;
671      }
672    }
# Line 653 | Line 675 | add_user_host(const char *user, const ch
675    strlcpy(nameh->name, user, sizeof(nameh->name));
676  
677    nameh->gcount = 1;
678 +
679    if (!global)
680    {
681      if (hasident)
# Line 698 | Line 721 | delete_user_host(const char *user, const
721          nameh->gcount--;
722        if (!global)
723        {
724 <        if (nameh->lcount > 0)
725 <          nameh->lcount--;
726 <        if (hasident && nameh->icount > 0)
727 <          nameh->icount--;
724 >        if (nameh->lcount > 0)
725 >          nameh->lcount--;
726 >        if (hasident && nameh->icount > 0)
727 >          nameh->icount--;
728        }
729  
730        if (nameh->gcount == 0 && nameh->lcount == 0)
731        {
732 <        dlinkDelete(&nameh->node, &found_userhost->list);
733 <        BlockHeapFree(namehost_heap, nameh);
732 >        dlinkDelete(&nameh->node, &found_userhost->list);
733 >        BlockHeapFree(namehost_heap, nameh);
734        }
735  
736        if (dlink_list_length(&found_userhost->list) == 0)
737        {
738 <        hash_del_userhost(found_userhost);
739 <        BlockHeapFree(userhost_heap, found_userhost);
738 >        hash_del_userhost(found_userhost);
739 >        BlockHeapFree(userhost_heap, found_userhost);
740        }
741  
742        return;
# Line 721 | Line 744 | delete_user_host(const char *user, const
744    }
745   }
746  
724 – /* find_or_add_userhost()
725 – *
726 – * inputs       - host name
727 – * output       - none
728 – * side effects - find UserHost * for given host name
729 – */
730 – static struct UserHost *
731 – find_or_add_userhost(const char *host)
732 – {
733 –  struct UserHost *userhost;
734 –
735 –  if ((userhost = hash_find_userhost(host)) != NULL)
736 –    return userhost;
737 –
738 –  userhost = BlockHeapAlloc(userhost_heap);
739 –  strlcpy(userhost->host, host, sizeof(userhost->host));
740 –  hash_add_userhost(userhost);
741 –
742 –  return userhost;
743 – }
744 –
747   /*
748   * Safe list code.
749   *

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)