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

Comparing ircd-hybrid-8/src/channel.c (file contents):
Revision 1173 by michael, Sun Aug 14 00:23:02 2011 UTC vs.
Revision 1203 by michael, Tue Aug 23 20:06:08 2011 UTC

# Line 48 | Line 48 | struct config_channel_entry ConfigChanne
48   dlink_list global_channel_list = { NULL, NULL, 0 };
49   BlockHeap *ban_heap;    /*! \todo ban_heap shouldn't be a global var */
50  
51 static BlockHeap *topic_heap = NULL;
51   static BlockHeap *member_heap = NULL;
52   static BlockHeap *channel_heap = NULL;
53  
# Line 68 | Line 67 | init_channels(void)
67  
68    channel_heap = BlockHeapCreate("channel", sizeof(struct Channel), CHANNEL_HEAP_SIZE);
69    ban_heap = BlockHeapCreate("ban", sizeof(struct Ban), BAN_HEAP_SIZE);
71  topic_heap = BlockHeapCreate("topic", TOPICLEN+1 + USERHOST_REPLYLEN, TOPIC_HEAP_SIZE);
70    member_heap = BlockHeapCreate("member", sizeof(struct Membership), CHANNEL_HEAP_SIZE*2);
71   }
72  
# Line 407 | Line 405 | destroy_channel(struct Channel *chptr)
405    free_channel_list(&chptr->exceptlist);
406    free_channel_list(&chptr->invexlist);
407  
410  /* Free the topic */
411  free_topic(chptr);
412
408    dlinkDelete(&chptr->node, &global_channel_list);
409    hash_del_channel(chptr);
410  
# Line 857 | Line 852 | check_splitmode(void *unused)
852    }
853   }
854  
860 /*! \brief Allocates a new topic
861 * \param chptr Channel to allocate a new topic for
862 */
863 static void
864 allocate_topic(struct Channel *chptr)
865 {
866  void *ptr = NULL;
867
868  if (chptr == NULL)
869    return;
870
871  ptr = BlockHeapAlloc(topic_heap);  
872
873  /* Basically we allocate one large block for the topic and
874   * the topic info.  We then split it up into two and shove it
875   * in the chptr
876   */
877  chptr->topic       = ptr;
878  chptr->topic_info  = (char *)ptr + TOPICLEN+1;
879  *chptr->topic      = '\0';
880  *chptr->topic_info = '\0';
881 }
882
883 void
884 free_topic(struct Channel *chptr)
885 {
886  void *ptr = NULL;
887  assert(chptr);
888  if (chptr->topic == NULL)
889    return;
890
891  /*
892   * If you change allocate_topic you MUST change this as well
893   */
894  ptr = chptr->topic;
895  BlockHeapFree(topic_heap, ptr);    
896  chptr->topic      = NULL;
897  chptr->topic_info = NULL;
898 }
899
855   /*! \brief Sets the channel topic for chptr
856   * \param chptr      Pointer to struct Channel
857   * \param topic      The topic string
# Line 907 | Line 862 | void
862   set_channel_topic(struct Channel *chptr, const char *topic,
863                    const char *topic_info, time_t topicts)
864   {
865 <  if (!EmptyString(topic))
866 <  {
867 <    if (chptr->topic == NULL)
913 <      allocate_topic(chptr);
914 <
915 <    strlcpy(chptr->topic, topic, TOPICLEN+1);
916 <    strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN);
917 <    chptr->topic_time = topicts;
918 <  }
919 <  else
920 <  {
921 <    /*
922 <     * Do not reset chptr->topic_time here, it's required for
923 <     * bursting topics properly.
924 <     */
925 <    if (chptr->topic != NULL)
926 <      free_topic(chptr);
927 <  }
865 >  strlcpy(chptr->topic, topic, sizeof(chptr->topic));
866 >  strlcpy(chptr->topic_info, topic_info, sizeof(chptr->topic_info));
867 >  chptr->topic_time = topicts;
868   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines