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 short *sp, 15: *pp; 16: #endif MTR 17: 18: if (lo == 0 && (lo = mp -> lowmsg) == 0) 19: lo = 1; 20: if (hi < mp -> hghmsg) 21: hi = mp -> hghmsg + (MAXFOLDER - mp -> nummsg); 22: if (hi <= mp -> hghmsg) 23: hi = mp -> hghmsg + MAXFOLDER; 24: if (lo == mp -> lowmsg && hi == mp -> hghmsg) 25: return mp; 26: 27: #ifndef MTR 28: mp = (struct msgs *) realloc ((char *) mp, MSIZE (mp, lo, hi)); 29: if (mp == NULL) 30: adios (NULLCP, "unable to re-allocate folder storage"); 31: #else MTR 32: if ((sp = (short *) calloc ((unsigned) 1, MSIZEX (mp, lo, hi))) == NULL) 33: adios (NULLCP, "unable to re-allocate messages storage"); 34: 35: pp = sp - lo; 36: if (pp < 0) 37: adios (NULLCP, "m_remsg() botch -- you lose big[1]"); 38: for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++) 39: pp[msgnum] = mp -> msgstats[msgnum]; 40: free ((char *) mp -> msgbase); 41: mp -> msgstats = sp; 42: #endif MTR 43: mp -> lowoff = lo; 44: mp -> hghoff = hi; 45: #ifdef MTR 46: mp -> msgstats = (mp -> msgbase = mp -> msgstats) - mp -> lowoff; 47: if (mp -> msgstats < 0) 48: adios (NULLCP, "m_remsg() botch -- you lose big[2]"); 49: #endif MTR 50: for (msgnum = mp -> lowmsg - 1; msgnum >= lo; msgnum--) 51: mp -> msgstats[msgnum] = NULL; 52: for (msgnum = mp -> hghmsg + 1; msgnum <= hi; msgnum++) 53: mp -> msgstats[msgnum] = NULL; 54: 55: return mp; 56: }