From 5c46f7488eb7cb89dea5044968e0360d6ed66789 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 00:36:43 -1100 Subject: [PATCH] Error check things --- src/cc/rogue/list.c | 16 +++++++++++++--- src/cc/rogue/pack.c | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 40f141861..68d889d8b 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -24,17 +24,24 @@ int total = 0; /* total dynamic memory bytes */ * Free up an item */ +#define ENABLE_DEBUG +#define MAX_DEBUGPTRS 100000 + int32_t itemcounter; -THING *thingptrs[100000]; +THING *thingptrs[MAX_DEBUGPTRS]; int32_t numptrs; int32_t thing_find(THING *item) { +#ifdef ENABLE_DEBUG int32_t i; for (i=0; il_next = NULL; item->l_prev = NULL; return item; diff --git a/src/cc/rogue/pack.c b/src/cc/rogue/pack.c index 362c65412..8ad899c7b 100644 --- a/src/cc/rogue/pack.c +++ b/src/cc/rogue/pack.c @@ -466,7 +466,14 @@ get_item(struct rogue_state *rs,char *purpose, int type) return NULL; } else + { + if ( thing_find(obj) < 0 ) + { + fprintf(stderr,"cant find thing.%p in list\n",obj); sleep(3); + return(NULL); + } return obj; + } } } return NULL;