MCPcopy Create free account
hub / github.com/NetHack/NetHack / optionMemStats

Function optionMemStats

outdated/sys/mac/mrecover.c:631–681  ·  view source on GitHub ↗

show memory stats: FreeMem, MaxBlock, PurgeSpace, and StackSpace */

Source from the content-addressed store, hash-verified

629
630/* show memory stats: FreeMem, MaxBlock, PurgeSpace, and StackSpace */
631static void
632optionMemStats()
633{
634 unsigned char *pFormat = "\pFree:#k Max:#k Purge:#k Stack:#k";
635 char *pSub = "#"; /* not a pascal string */
636 unsigned char nBuf[16];
637 long nStat, contig;
638 Handle strHnd;
639 long nOffset;
640 short i;
641
642 if (wnEvt.modifiers & shiftKey)
643 adjustMemory();
644
645 if (!(strHnd = NewHandle((Size) 128))) {
646 note(noErr, alidNote, "\pOops: Memory stats unavailable!");
647 return;
648 }
649
650 SetString((StringHandle) strHnd, pFormat);
651 nOffset = 1L;
652
653 for (i = 1; i <= 4; i++) {
654 /* get the replacement number stat */
655 switch (i) {
656 case 1:
657 nStat = FreeMem();
658 break;
659 case 2:
660 nStat = MaxBlock();
661 break;
662 case 3:
663 PurgeSpace(&nStat, &contig);
664 break;
665 case 4:
666 nStat = StackSpace();
667 break;
668 }
669
670 NumToString((nStat >> 10), *(Str255 *) &nBuf);
671
672 **strHnd += nBuf[0] - 1;
673 nOffset =
674 Munger(strHnd, nOffset, (Ptr) pSub, 1L, (Ptr) &nBuf[1], nBuf[0]);
675 }
676
677 MoveHHi(strHnd);
678 HLock(strHnd);
679 note(noErr, alidNote, (unsigned char *) *strHnd);
680 DisposHandle(strHnd);
681}
682
683static void
684RecoverMenuEvent(long menuEntry)

Callers 1

RecoverMenuEventFunction · 0.85

Calls 2

adjustMemoryFunction · 0.85
noteFunction · 0.85

Tested by

no test coverage detected