fmt_ptr (trunk only)
fmt_ptr() is no longer dependant on WIZARD or MONITOR_HEAP, so that it can be used in panic messages.
This commit is contained in:
+11
-1
@@ -190,11 +190,21 @@
|
|||||||
|
|
||||||
#endif /* NHSTDC */
|
#endif /* NHSTDC */
|
||||||
|
|
||||||
|
|
||||||
#ifndef genericptr_t
|
#ifndef genericptr_t
|
||||||
typedef genericptr genericptr_t; /* (void *) or (char *) */
|
typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MICRO) || defined(WIN32)
|
||||||
|
/* we actually want to know which systems have an ANSI run-time library
|
||||||
|
* to know which support the new %p format for printing pointers.
|
||||||
|
* due to the presence of things like gcc, NHSTDC is not a good test.
|
||||||
|
* so we assume microcomputers have all converted to ANSI and bigger
|
||||||
|
* computers which may have older libraries give reasonable results with
|
||||||
|
* the cast.
|
||||||
|
*/
|
||||||
|
# define HAS_PTR_FMT
|
||||||
|
#endif
|
||||||
|
#define FMT_PTR_BUFSIZ 20 /* buffer size for ptr address as text */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* According to ANSI, prototypes for old-style declarations must widen the
|
* According to ANSI, prototypes for old-style declarations must widen the
|
||||||
|
|||||||
+3
-19
@@ -53,21 +53,7 @@ register unsigned int lth;
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef HAS_PTR_FMT
|
||||||
#if defined(MONITOR_HEAP) || defined(WIZARD)
|
|
||||||
|
|
||||||
# if defined(MICRO) || defined(WIN32)
|
|
||||||
/* we actually want to know which systems have an ANSI run-time library
|
|
||||||
* to know which support the new %p format for printing pointers.
|
|
||||||
* due to the presence of things like gcc, NHSTDC is not a good test.
|
|
||||||
* so we assume microcomputers have all converted to ANSI and bigger
|
|
||||||
* computers which may have older libraries give reasonable results with
|
|
||||||
* the cast.
|
|
||||||
*/
|
|
||||||
# define MONITOR_PTR_FMT
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef MONITOR_PTR_FMT
|
|
||||||
# define PTR_FMT "%p"
|
# define PTR_FMT "%p"
|
||||||
# define PTR_TYP genericptr_t
|
# define PTR_TYP genericptr_t
|
||||||
# else
|
# else
|
||||||
@@ -85,8 +71,6 @@ char *buf;
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MONITOR_HEAP
|
#ifdef MONITOR_HEAP
|
||||||
|
|
||||||
/* If ${NH_HEAPLOG} is defined and we can create a file by that name,
|
/* If ${NH_HEAPLOG} is defined and we can create a file by that name,
|
||||||
@@ -108,7 +92,7 @@ const char *file;
|
|||||||
int line;
|
int line;
|
||||||
{
|
{
|
||||||
long *ptr = alloc(lth);
|
long *ptr = alloc(lth);
|
||||||
char ptr_address[20];
|
char ptr_address[FMT_PTR_BUFSIZ];
|
||||||
|
|
||||||
if (!tried_heaplog) heapmon_init();
|
if (!tried_heaplog) heapmon_init();
|
||||||
if (heaplog)
|
if (heaplog)
|
||||||
@@ -128,7 +112,7 @@ genericptr_t ptr;
|
|||||||
const char *file;
|
const char *file;
|
||||||
int line;
|
int line;
|
||||||
{
|
{
|
||||||
char ptr_address[20];
|
char ptr_address[FMT_PTR_BUFSIZ];
|
||||||
|
|
||||||
if (!tried_heaplog) heapmon_init();
|
if (!tried_heaplog) heapmon_init();
|
||||||
if (heaplog)
|
if (heaplog)
|
||||||
|
|||||||
+1
-1
@@ -582,7 +582,7 @@ int
|
|||||||
wiz_light_sources()
|
wiz_light_sources()
|
||||||
{
|
{
|
||||||
winid win;
|
winid win;
|
||||||
char buf[BUFSZ], arg_address[20];
|
char buf[BUFSZ], arg_address[FMT_PTR_BUFSIZ];
|
||||||
light_source *ls;
|
light_source *ls;
|
||||||
|
|
||||||
win = create_nhwindow(NHW_MENU); /* corner text window */
|
win = create_nhwindow(NHW_MENU); /* corner text window */
|
||||||
|
|||||||
+3
-2
@@ -1840,7 +1840,8 @@ obj_sanity_check()
|
|||||||
struct obj *obj;
|
struct obj *obj;
|
||||||
struct monst *mon;
|
struct monst *mon;
|
||||||
const char *mesg;
|
const char *mesg;
|
||||||
char obj_address[20], mon_address[20]; /* room for formatted pointers */
|
char obj_address[FMT_PTR_BUFSIZ],
|
||||||
|
mon_address[FMT_PTR_BUFSIZ]; /* room for formatted pointers */
|
||||||
|
|
||||||
mesg = "fobj sanity";
|
mesg = "fobj sanity";
|
||||||
for (obj = fobj; obj; obj = obj->nobj) {
|
for (obj = fobj; obj; obj = obj->nobj) {
|
||||||
@@ -1948,7 +1949,7 @@ check_contained(container, mesg)
|
|||||||
const char *mesg;
|
const char *mesg;
|
||||||
{
|
{
|
||||||
struct obj *obj;
|
struct obj *obj;
|
||||||
char obj1_address[20], obj2_address[20];
|
char obj1_address[FMT_PTR_BUFSIZ], obj2_address[FMT_PTR_BUFSIZ];
|
||||||
|
|
||||||
for (obj = container->cobj; obj; obj = obj->nobj) {
|
for (obj = container->cobj; obj; obj = obj->nobj) {
|
||||||
if (obj->where != OBJ_CONTAINED)
|
if (obj->where != OBJ_CONTAINED)
|
||||||
|
|||||||
+3
-3
@@ -482,9 +482,9 @@ monsndx(ptr) /* return an index into the mons array */
|
|||||||
|
|
||||||
i = (int)(ptr - &mons[0]);
|
i = (int)(ptr - &mons[0]);
|
||||||
if (i < LOW_PM || i >= NUMMONS) {
|
if (i < LOW_PM || i >= NUMMONS) {
|
||||||
/* ought to switch this to use `fmt_ptr' */
|
char ptr_address[FMT_PTR_BUFSIZ];
|
||||||
panic("monsndx - could not index monster (%lx)",
|
panic("monsndx - could not index monster (%s)",
|
||||||
(unsigned long)ptr);
|
fmt_ptr((genericptr_t)ptr, ptr_address));
|
||||||
return NON_PM; /* will not get here */
|
return NON_PM; /* will not get here */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1368,7 +1368,7 @@ print_queue(win, base)
|
|||||||
timer_element *base;
|
timer_element *base;
|
||||||
{
|
{
|
||||||
timer_element *curr;
|
timer_element *curr;
|
||||||
char buf[BUFSZ], arg_address[20];
|
char buf[BUFSZ], arg_address[FMT_PTR_BUFSIZ];
|
||||||
|
|
||||||
if (!base) {
|
if (!base) {
|
||||||
putstr(win, 0, "<empty>");
|
putstr(win, 0, "<empty>");
|
||||||
@@ -1417,7 +1417,7 @@ void
|
|||||||
timer_sanity_check()
|
timer_sanity_check()
|
||||||
{
|
{
|
||||||
timer_element *curr;
|
timer_element *curr;
|
||||||
char obj_address[20];
|
char obj_address[FMT_PTR_BUFSIZ];
|
||||||
|
|
||||||
/* this should be much more complete */
|
/* this should be much more complete */
|
||||||
for (curr = timer_base; curr; curr = curr->next)
|
for (curr = timer_base; curr; curr = curr->next)
|
||||||
|
|||||||
Reference in New Issue
Block a user