]>
diplodocus.org Git - nmh/blob - sbr/folder_realloc.c
827d3b17722c2b10d2feacaac4d759571e23564d
1 /* folder_realloc.c -- realloc a folder/msgs structure
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
13 * Reallocate some of the space in the folder
14 * structure (currently just message status array).
16 * Return pointer to new folder structure.
17 * If error, return NULL.
21 folder_realloc (struct msgs
*mp
, int lo
, int hi
)
23 struct bvector
*tmpstats
, *t
;
29 die("BUG: called folder_realloc with lo (%d) < 1", lo
);
31 die("BUG: called folder_realloc with hi (%d) < 1", hi
);
32 if (mp
->nummsg
> 0 && lo
> mp
->lowmsg
)
33 die("BUG: called folder_realloc with lo (%d) > mp->lowmsg (%d)",
35 if (mp
->nummsg
> 0 && hi
< mp
->hghmsg
)
36 die("BUG: called folder_realloc with hi (%d) < mp->hghmsg (%d)",
39 /* Check if we really need to reallocate anything */
40 if (lo
== mp
->lowoff
&& hi
== mp
->hghoff
)
43 /* first allocate the new message status space */
44 mp
->num_msgstats
= MSGSTATNUM (lo
, hi
);
45 tmpstats
= mh_xmalloc (MSGSTATSIZE(mp
));
46 for (i
= 0, t
= tmpstats
; i
< mp
->num_msgstats
; ++i
, ++t
) {
50 /* then copy messages status array with shift */
52 for (msgnum
= mp
->lowmsg
; msgnum
<= mp
->hghmsg
; msgnum
++)
53 bvector_copy (tmpstats
+ msgnum
- lo
, msgstat (mp
, msgnum
));
56 mp
->msgstats
= tmpstats
;