Add detailed Z_Malloc error messages

This commit is contained in:
Lephenixnoir 2021-09-17 07:43:19 +02:00
parent 0aaed2e7a5
commit 828c9329a3
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 21 additions and 2 deletions

View File

@ -1,4 +1,6 @@
#include "cgdoom-ui.h"
#include "i_system.h"
#include "z_zone.h"
#include <stdio.h>
#include <stdlib.h>
@ -479,6 +481,25 @@ void UI_Error(const char *fmt, va_list args)
while(*str && isspace_(*str)) str++;
}
/* Additional info for heap errors */
if(!strncmp(fmt, "Z_", 2)) {
y += 12;
UI_Print(LAYOUT_LEFT, y, 0x0000, UI_LEFT, "Free memory in heap:", -1);
y += 14;
for (int i = 0;; i++) {
int size;
byte *ptr = I_ZoneBase(&size, i);
if (!ptr) break;
UI_Printf(LAYOUT_LEFT, y, 0x0000, UI_LEFT,
"Zone #%d: %d/%d kB (largest block %d B)",
i, Z_FreeMemory(i) >> 10, size >> 10, Z_LargestFreeBlock(i));
y += 14;
}
}
Bdisp_FrameAndColor(3, 16);
Bdisp_FrameAndColor(1, 0);
Bdisp_PutDisp_DD();

View File

@ -35,8 +35,6 @@ void I_Error (const char *error, ...);
//force compiler error on use following:
#define strcpy 12
#define strnicmp 22
#define strncmp 27
#define strcmp 33
//return ptr to flash
int FindInFlash(const void **buf, int size, int readpos);