Hoi.

[2020-03-19 12:33] Philipp Takacs <phil...@bureaucracy.de>
>
> I have also removed the
> clear_msg_flags loop from folder_read and folder_realloc. In most cases
> we use calloc, so this isn't necesarry. At one place in folder_realloc
> realloc is used. There I have add a memset.
> 
> comment?

Why were (in the section down below) only the flags outside the
current message range cleared? Now you clear all flags. Does that
change the behavior? Or, if your memset() clears only specific
parts, you probably should put a comment there to explain it, as
this might not be what the programmer usually expects from a
memset() after a (re)alloc().

Apart from that, your changes look and sound sensible.


meillo


> From 937c01f62952147a8ff853d8a103dbe8465cb90e Mon Sep 17 00:00:00 2001
> From: Philipp Takacs <phil...@bureaucracy.de>
> Date: Wed, 18 Mar 2020 21:46:30 +0100
> Subject: [PATCH 3/3] use memset to clear the msgstats in folder_realloc
> 
> ---
>  sbr/folder_realloc.c | 16 +---------------
>  1 file changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/sbr/folder_realloc.c b/sbr/folder_realloc.c
> index 64a66409..781e8bdc 100644
> --- a/sbr/folder_realloc.c
> +++ b/sbr/folder_realloc.c
> @@ -46,6 +46,7 @@ folder_realloc(struct msgs *mp, int lo, int hi)
>               ** just realloc the message status array.
>               */
>               mp->msgstats = mh_xrealloc(mp->msgstats, MSGSTATSIZE(mp, lo, 
> hi));
> +             memset(mp->msgstats + mp->hghoff - lo, 0, hi - mp->hghoff);
>       } else {
>               /*
>               ** We are changing the offset of the message status
> @@ -69,20 +70,5 @@ folder_realloc(struct msgs *mp, int lo, int hi)
>       mp->lowoff = lo;
>       mp->hghoff = hi;
>  
> -     /*
> -     ** Clear all the flags for entries outside
> -     ** the current message range for this folder.
> -     */
> -     if (mp->nummsg > 0) {
> -             for (msgnum = mp->lowoff; msgnum < mp->lowmsg; msgnum++)
> -                     clear_msg_flags(mp, msgnum);
> -             for (msgnum = mp->hghmsg + 1; msgnum <= mp->hghoff; msgnum++)
> -                     clear_msg_flags(mp, msgnum);
> -     } else {
> -             /* no messages, so clear entire range */
> -             for (msgnum = mp->lowoff; msgnum <= mp->hghoff; msgnum++)
> -                     clear_msg_flags(mp, msgnum);
> -     }
> -
>       return mp;
>  }
> -- 
> 2.20.1
> 

Reply via email to