|
|
1.1 root 1: #include <doscalls.h>
2: #include <dos.h>
3: #include "ssedefs.h"
4:
5:
6:
7:
8: /*** allocseg - allocates segments.
9: *
10: * allocseg uses DOSALLOCSEG to allocate segments from DOS.
11: *
12: * This routine will return an error code if it is unable to
13: * allocate the segment.
14: *
15: * EXIT rc - return code of DOSALLOCSEG
16: *
17: *
18: * EFFECTS : allocates memory from DOS
19: * modifies SegTable (by adding a new segment)
20: * modifies TotalSegs (by incrementing it by one)
21: */
22:
23: short allocseg()
24: {
25: short rc; /* return code of DOS call */
26:
27: rc = DOSALLOCSEG(SEGSIZE,
28: (unsigned far *)&(SegTable[TotalSegs].segment),
29: NOTSHARED);
30:
31: if (rc == 0) {
32: SegTable[TotalSegs].free = SEGSIZE;
33: ++TotalSegs;
34: }
35:
36: return(rc);
37: } /* end allocseg */
38:
39:
40:
41:
42: /*** freesegs - free segments
43: *
44: * freesegs uses DOSFREESEG to free all the segments
45: * allocated by allocseg.
46: *
47: * EFFECTS: frees all alocated memory (segments) to DOS
48: * sets TotalSegs to zero
49: * makes SegTable invalid
50: */
51:
52: void freesegs()
53: {
54: register unsigned short i;
55:
56: for (i = 0; i < TotalSegs; i++) {
57: DOSFREESEG(SegTable[i].segment);
58: }
59: TotalSegs = 0;
60: } /* end freesegs */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.