0
|
1 /* m_remsg.c - realloc a msgs structure */
|
|
2 #ifndef lint
|
|
3 static char ident[] = "@(#)$Id$";
|
|
4 #endif /* lint */
|
|
5
|
|
6 #include "../h/mh.h"
|
|
7 #include <stdio.h>
|
|
8
|
|
9
|
|
10 struct msgs *m_remsg (mp, lo, hi)
|
|
11 register struct msgs *mp;
|
|
12 int lo,
|
|
13 hi;
|
|
14 {
|
|
15 int msgnum;
|
|
16 #ifdef MTR
|
|
17 register int *sp,
|
|
18 *pp;
|
|
19 #endif /* MTR */
|
|
20
|
|
21 if (lo == 0 && (lo = mp -> lowmsg) == 0)
|
|
22 lo = 1;
|
|
23 if (hi < mp -> hghmsg)
|
|
24 hi = mp -> hghmsg + (MAXFOLDER - mp -> nummsg);
|
|
25 if (hi <= mp -> hghmsg)
|
|
26 hi = mp -> hghmsg + MAXFOLDER;
|
|
27 if (lo == mp -> lowmsg && hi == mp -> hghmsg)
|
|
28 return mp;
|
|
29
|
|
30 #ifndef MTR
|
|
31 mp = (struct msgs *) realloc ((char *) mp, MHSIZE (mp, lo, hi));
|
|
32 if (mp == NULL)
|
|
33 adios (NULLCP, "unable to re-allocate folder storage");
|
|
34 #else /* MTR */
|
|
35 if ((sp = (int *) calloc ((unsigned) 1, MHSIZEX (mp, lo, hi))) == NULL)
|
|
36 adios (NULLCP, "unable to re-allocate messages storage");
|
|
37
|
|
38 pp = sp - lo;
|
|
39 if (pp < (int *)0)
|
|
40 adios (NULLCP, "m_remsg() botch -- you lose big[1]");
|
|
41 for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
|
|
42 pp[msgnum] = mp -> msgstats[msgnum];
|
|
43 free ((char *) mp -> msgbase);
|
|
44 mp -> msgstats = sp;
|
|
45 #endif /* MTR */
|
|
46 mp -> lowoff = lo;
|
|
47 mp -> hghoff = hi;
|
|
48 #ifdef MTR
|
|
49 mp -> msgstats = (mp -> msgbase = mp -> msgstats) - mp -> lowoff;
|
|
50 if (mp -> msgstats < (int *)0)
|
|
51 adios (NULLCP, "m_remsg() botch -- you lose big[2]");
|
|
52 #endif /* MTR */
|
|
53 for (msgnum = mp -> lowmsg - 1; msgnum >= lo; msgnum--)
|
|
54 mp -> msgstats[msgnum] = 0;
|
|
55 for (msgnum = mp -> hghmsg + 1; msgnum <= hi; msgnum++)
|
|
56 mp -> msgstats[msgnum] = 0;
|
|
57
|
|
58 return mp;
|
|
59 }
|