File:  [OS/2 SDKs] / os2sdk / demos / apps / sse / ssemem.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:05 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

/* Created by Microsoft Corp. 1987  */

#define INCL_DOSMEMMGR

#include <os2def.h>
#include <bsedos.h>
#include "ssedefs.h"




/*** allocseg - allocates segments.
 *
 *   allocseg uses DosAllocSeg to allocate segments from OS/2.
 *
 *   This routine will return an error code if it is unable to
 *     allocate the segment.
 *
 *   EXIT   rc	- return code of DosAllocSeg
 *
 *
 *   EFFECTS : allocates memory from OS/2
 *	       modifies SegTable (by adding a new segment)
 *	       modifies TotalSegs (by incrementing it by one)
 */

SHORT allocseg()
{
  SHORT  rc;	/* return code of OS/2 call */

  rc = DosAllocSeg(SEGSIZE,
		   &(SegTable[TotalSegs].segment),
		   NOTSHARED);

  if (rc == 0) {
      SegTable[TotalSegs].free = SEGSIZE;
      ++TotalSegs;
  }

  return(rc);
} /* end allocseg */




/*** freesegs - free segments
 *
 *   freesegs uses DosFreeSeg to free all the segments
 *     allocated by allocseg.
 *
 *   EFFECTS: frees all alocated memory (segments) to OS/2
 *	      sets TotalSegs to zero
 *	      makes SegTable invalid
 */

void freesegs()
{
  register USHORT i;

  for (i = 0; i < TotalSegs; i++) {
      DosFreeSeg(SegTable[i].segment);
  }
  TotalSegs = 0;
} /* end freesegs */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.