/[mailutils]/mailutils/mailbox/mh/mbox.c
ViewVC logotype

Diff of /mailutils/mailbox/mh/mbox.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.42 by gray, Sun Mar 23 22:49:54 2003 UTC revision 1.43 by gray, Thu Sep 18 10:01:05 2003 UTC
# Line 174  static void _mh_message_insert __P((stru Line 174  static void _mh_message_insert __P((stru
174  static void _mh_message_delete __P((struct _mh_data *mhd,  static void _mh_message_delete __P((struct _mh_data *mhd,
175                                      struct _mh_message *msg));                                      struct _mh_message *msg));
176  static int mh_pool_open __P((struct _mh_message *mhm));  static int mh_pool_open __P((struct _mh_message *mhm));
177    static int mh_pool_open_count __P((struct _mh_data *mhd));
178    static struct _mh_message **mh_pool_lookup __P((struct _mh_message *mhm));
179    
180  static int mh_envelope_date __P((envelope_t envelope, char *buf, size_t len,  static int mh_envelope_date __P((envelope_t envelope, char *buf, size_t len,
181                                   size_t *psize));                                   size_t *psize));
182  static int mh_envelope_sender __P((envelope_t envelope, char *buf, size_t len,  static int mh_envelope_sender __P((envelope_t envelope, char *buf, size_t len,
183                                     size_t *psize));                                     size_t *psize));
184    
185  /* Should be in an other header file.  */  /* Should be in other header file.  */
186  extern int mh_message_number __P ((message_t msg, size_t *pnum));  extern int mh_message_number __P ((message_t msg, size_t *pnum));
187    
188  /* Return filename for the message.  /* Return filename for the message.
# Line 912  static void Line 914  static void
914  _mh_message_delete (struct _mh_data *mhd, struct _mh_message *msg)  _mh_message_delete (struct _mh_data *mhd, struct _mh_message *msg)
915  {  {
916    struct _mh_message *p;    struct _mh_message *p;
917      struct _mh_message **pp = mh_pool_lookup (msg);
918    
919      if (pp)
920        *pp = NULL;
921      
922    if ((p = msg->next) != NULL)    if ((p = msg->next) != NULL)
923      p->prev = msg->prev;      p->prev = msg->prev;
924    else    else
# Line 1162  mh_get_size (mailbox_t mailbox ARG_UNUSE Line 1168  mh_get_size (mailbox_t mailbox ARG_UNUSE
1168    
1169  /* Return number of open streams residing in a message pool */  /* Return number of open streams residing in a message pool */
1170  static int  static int
1171  mh_pool_open_count(struct _mh_data *mhd)  mh_pool_open_count (struct _mh_data *mhd)
1172  {  {
1173    int cnt = mhd->pool_last - mhd->pool_first;    int cnt = mhd->pool_last - mhd->pool_first;
1174    if (cnt < 0)    if (cnt < 0)
# Line 1171  mh_pool_open_count(struct _mh_data *mhd) Line 1177  mh_pool_open_count(struct _mh_data *mhd)
1177  }  }
1178    
1179  /* Look up a _mh_message in the pool of open messages.  /* Look up a _mh_message in the pool of open messages.
1180     Returns 1 if the message is found in the pool, and 0 otherwise. */     If the message is found in the pool, returns the address of
1181  static int     the pool slot occupied by it. Otherwise returns NULL. */
1182    static struct _mh_message **
1183  mh_pool_lookup (struct _mh_message *mhm)  mh_pool_lookup (struct _mh_message *mhm)
1184  {  {
1185    struct _mh_data *mhd = mhm->mhd;    struct _mh_data *mhd = mhm->mhd;
# Line 1181  mh_pool_lookup (struct _mh_message *mhm) Line 1188  mh_pool_lookup (struct _mh_message *mhm)
1188    for (i = mhd->pool_first; i != mhd->pool_last; )    for (i = mhd->pool_first; i != mhd->pool_last; )
1189      {      {
1190        if (mhd->msg_pool[i] == mhm)        if (mhd->msg_pool[i] == mhm)
1191          return 1;          return &mhd->msg_pool[i];
1192        if (++i == MAX_OPEN_STREAMS)        if (++i == MAX_OPEN_STREAMS)
1193          i = 0;          i = 0;
1194      }      }
1195    return 0;    return NULL;
1196  }  }
1197    
1198  /* Open a stream associated with the message mhm. If the stream is  /* Open a stream associated with the message mhm. If the stream is
1199     already open, do nothing */     already open, do nothing.
1200       NOTE: We could have reused the NULL holes in the msg_pool, but
1201       that hardly is worth the effort, since the holes appear only when
1202       expunging. On the other hand this may be useful when MAX_OPEN_STREAMS
1203       size is very big. "Premature optimization is the root of all evil" */
1204  static int  static int
1205  mh_pool_open (struct _mh_message *mhm)  mh_pool_open (struct _mh_message *mhm)
1206  {  {

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26