Category : C++ Source Code
Archive   : VMVCPP.ZIP
Filename : VMFREE.C

 
Output of file : VMFREE.C contained in archive : VMVCPP.ZIP
/***
* vmfree.c -
*
* Copyright (c) 1989-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
*
* PUBLIC Function List
*
* VmFreePageVp
* This function frees a virtual page at a specific virtual
* address.
*
* VmFreePageVpCb
* This function frees the range of virtual pages starting at the
* specified virtual address spanning the specified number of bytes.
*
*
*******************************************************************************/

#pragma title("Virtual Memory Manager")
#pragma subtitle("Core routines")

#include
#include
#include
#include
#include
#include

#include

#pragma page()

#if VMFREE

void PUBLIC __VmFreePageVp(VPVOID vp)
{
HPGD hpgd;
PPTE ppte;

VmTracePrintf(("VmFreePageVp: vp = %08lX.\n", vp));

/* If this page is in memory, then discard it. */

if ((hpgd = __HpgdSearchCache(VpPageOfVp(vp))) != hpgdNil)
{
PpgdOfHpgd(hpgd)->cLock = 0;

if (!(PpgdOfHpgd(hpgd)->Flags & fEmsPgd))
__VmRemovePgdFromCache(hpgd);

PpgdOfHpgd(hpgd)->Flags &= ~(fAllocatedPgd | fDirtyPgd);
PpgdOfHpgd(hpgd)->timeRef = 0;
}


/* Load page table entry for this page to determine current location */
/* This page better have been allocated previously. */

if (vp < vpptMax)
ppte = &_ptRoot[PageOfVp(vp)];
else
ppte = __PVmLoadVp(VppteOfVp(vp), FALSE);

Assert(ppte != NULL);
Assert(*ppte & fAllocatedPte);

*ppte &= ~fAllocatedPte;

if (*ppte & fXmsPte)
__VmFreeXmsPage(ppte);

else if (*ppte & fEmsPte)
__VmFreeEmsPage(ppte);

else
__VmFreeDiskPage(ppte);

}


#endif /* VMFREE */

#pragma page()

#if VMFREE

void PUBLIC __VmFreePageVpCb(VPVOID vp, unsigned long cb)
{
unsigned cPage;
unsigned iPage;

VmTracePrintf(("VmFreePageVpCb: vp = %08lX, cb = %08lX.\n", vp, cb));

Assert((vp & (cbVmPage - 1UL)) == 0);
Assert(vp + cb > vp);

cPage = (unsigned) ((cb + cbVmPage - 1UL) / cbVmPage);
for (iPage = 0; iPage < cPage; iPage++)
{
__VmFreePageVp(vp);
vp += cbVmPage;
}
}


#endif /* VMFREE */


  3 Responses to “Category : C++ Source Code
Archive   : VMVCPP.ZIP
Filename : VMFREE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/