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

Function overview_stats

src/dungeon.c:2757–2801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2755#ifndef SFCTOOL
2756
2757DISABLE_WARNING_FORMAT_NONLITERAL
2758
2759/* for '#stats' wizard-mode command, to show memory used for #overview data */
2760void
2761overview_stats(
2762 winid win, /* output window */
2763 const char *statsfmt, /* format */
2764 long *total_count, long *total_size) /* args for the format */
2765{
2766 char buf[BUFSZ], hdrbuf[QBUFSZ];
2767 long ocount, osize, bcount, bsize, acount, asize;
2768 struct cemetery *ce;
2769 mapseen *mptr;
2770
2771 ocount = bcount = acount = osize = bsize = asize = 0L;
2772 for (mptr = svm.mapseenchn; mptr; mptr = mptr->next) {
2773 ++ocount;
2774 osize += (long) sizeof *mptr;
2775 for (ce = mptr->final_resting_place; ce; ce = ce->next) {
2776 ++bcount;
2777 bsize += (long) sizeof *ce;
2778 }
2779 if (mptr->custom_lth) {
2780 ++acount;
2781 asize += (long) (mptr->custom_lth + 1);
2782 }
2783 }
2784
2785 Sprintf(hdrbuf, "general, size %ld", (long) sizeof (mapseen));
2786 Sprintf(buf, statsfmt, hdrbuf, ocount, osize);
2787 putstr(win, 0, buf);
2788 if (bcount) {
2789 Sprintf(hdrbuf, "cemetery, size %ld",
2790 (long) sizeof (struct cemetery));
2791 Sprintf(buf, statsfmt, hdrbuf, bcount, bsize);
2792 putstr(win, 0, buf);
2793 }
2794 if (acount) {
2795 Sprintf(hdrbuf, "annotations, text");
2796 Sprintf(buf, statsfmt, hdrbuf, acount, asize);
2797 putstr(win, 0, buf);
2798 }
2799 *total_count += ocount + bcount + acount;
2800 *total_size += osize + bsize + asize;
2801}
2802
2803RESTORE_WARNING_FORMAT_NONLITERAL
2804

Callers 1

wiz_show_statsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected