|
|
1.1 root 1: /* m_remsg.c - realloc a msgs structure */
2:
3: #include "../h/mh.h"
4: #include <stdio.h>
5:
6:
7: struct msgs *m_remsg (mp, lo, hi)
8: register struct msgs *mp;
9: int lo,
10: hi;
11: {
12: int msgnum;
13: #ifdef MTR
14: register int *sp, *pp;
15: #endif MTR
16:
17: if (lo == 0 && (lo = mp -> lowmsg) == 0)
18: lo = 1;
19: if (hi < mp -> hghmsg)
20: hi = mp -> hghmsg + (MAXFOLDER - mp -> nummsg);
21: if (hi <= mp -> hghmsg)
22: hi = mp -> hghmsg + MAXFOLDER;
23: if (lo == mp -> lowmsg && hi == mp -> hghmsg)
24: return mp;
25:
26: #ifndef MTR
27: mp = (struct msgs *) realloc ((char *) mp, MSGSIZE(mp, lo, hi));
28: if (mp == NULL)
29: adios (NULLCP, "unable to re-allocate folder storage");
30: #else MTR
31: if ((sp = (short *) calloc ((unsigned) 1, MSGSIZEX (mp, lo, hi))) == NULL)
32: adios (NULLCP, "unable to re-allocate messages storage");
33:
34: pp = sp - lo;
35: if (pp < 0)
36: adios (NULLCP, "m_remsg() botch -- you lose big[1]");
37: for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
38: pp[msgnum] = mp -> msgstats[msgnum];
39: free ((char *) mp -> msgbase);
40: mp -> msgstats = sp;
41: #endif MTR
42: mp -> lowoff = lo;
43: mp -> hghoff = hi;
44: #ifdef MTR
45: mp -> msgstats = (mp -> msgbase = mp -> msgstats) - mp -> lowoff;
46: if (mp -> msgstats < 0)
47: adios (NULLCP, "m_remsg() botch -- you lose big[2]");
48: #endif MTR
49: for (msgnum = mp -> lowmsg - 1; msgnum >= lo; msgnum--)
50: mp -> msgstats[msgnum] = NULL;
51: for (msgnum = mp -> hghmsg + 1; msgnum <= hi; msgnum++)
52: mp -> msgstats[msgnum] = NULL;
53:
54: return mp;
55: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.