making dmalloc work again

This commit is contained in:
Enno Rehling 2005-05-07 10:07:06 +00:00
parent ced0d324e6
commit 264880cc7b
7 changed files with 40 additions and 43 deletions

View File

@ -21,6 +21,12 @@ if ! $(CCACHE_DIR) {
Echo Compiling with ccache ;
}
if $(DMALLOC) {
Echo Compiling with dmalloc ;
CCFLAGS += -DUSE_DMALLOC ;
LINKFLAGS += -ldmalloc ;
}
if $(PROFILE) = 1 {
Echo Compiling with profiler ;
CCFLAGS += -pg -g ;

View File

@ -3911,11 +3911,6 @@ do_battle(void)
/* Auswirkungen berechnen: */
aftermath(b);
/*
#ifdef MALLOCDBG
assert(_CrtCheckMemory());
#endif
*/
/* Hier ist das Gefecht beendet, und wir können die
* Hilfsstrukturen * wieder löschen: */

View File

@ -97,7 +97,6 @@ promotelist(void *l, void *p)
insertlist((void_list **)l, (void_list *)p);
}
#ifndef MALLOCDBG
void
removelist(void *l, void *p)
{
@ -124,7 +123,6 @@ freelist(void *p1)
p = p2;
}
}
#endif
void
invert_list(void * heap)

View File

@ -89,7 +89,7 @@ mt_new_va(const char * name, ...)
typedef struct arg_type {
struct arg_type * next;
const char * name;
void (*free)(void*);
void (*release)(void*);
void* (*copy)(void*);
} arg_type;
@ -101,7 +101,7 @@ register_argtype(const char * name, void(*free_arg)(void*), void*(*copy_arg)(voi
arg_type * atype = (arg_type *)malloc(sizeof(arg_type));
atype->name = name;
atype->next = argtypes;
atype->free = free_arg;
atype->release = free_arg;
atype->copy = copy_arg;
argtypes = atype;
}
@ -130,7 +130,7 @@ static void
free_arg(const char * type, void * data)
{
arg_type * atype = find_argtype(type);
if (atype && atype->free) atype->free(data);
if (atype && atype->release) atype->release(data);
}
message *

View File

@ -34,37 +34,22 @@ extern "C" {
/**** ****
** Debugging Libraries **
**** ****/
/*
* MALLOCDBG is an integer >= 0 that specifies the level of
* debugging. 0 = no debugging, >= 1 increasing levels of
* debugging strength.
*/
#ifdef MPATROL
# ifndef MALLOCDBG
# define MALLOCDBG 1
# endif
# include <mpatrol.h>
#endif
#if defined __GNUC__
# define HAVE_INLINE
# define INLINE_FUNCTION __inline
#endif
#ifdef DMALLOC
# ifndef MALLOCDBG
# define MALLOCDBG 1
# endif
/* define USE_DMALLOC to enable use of the dmalloc library */
#ifdef USE_DMALLOC
# include <stdlib.h>
# include <string.h>
# include <dmalloc.h>
#endif
#if defined(_DEBUG) && defined(_MSC_VER)
/* define MALLOCDBG in project settings, not here! */
# ifdef MALLOCDBG
/* define CRTDBG to enable MSVC CRT Debug library functions */
#if defined(_DEBUG) && defined(_MSC_VER) && defined(CRTDBG)
# include <crtdbg.h>
# define _CRTDBG_MAP_ALLOC
# endif
#endif
/**** ****

View File

@ -410,9 +410,9 @@ game_done(void)
#include "magic.h"
#ifdef MALLOCDBG
#ifdef CRTDBG
void
init_malloc_debug(void)
init_crtdbg(void)
{
#if (defined(_MSC_VER))
# if MALLOCDBG == 2
@ -621,8 +621,11 @@ main(int argc, char *argv[])
return -1;
}
#endif
#ifdef MALLOCDBG
init_malloc_debug();
#ifdef CRTDBG
init_crtdbg();
#endif
#ifdef DMALLOC
init_dmalloc();
#endif
if ((i=read_args(argc, argv))!=0) return i;

View File

@ -466,9 +466,9 @@ report_cleanup();
#include "magic.h"
#ifdef MALLOCDBG
#ifdef CRTDBG
void
init_malloc_debug(void)
init_crtdbg(void)
{
#if (defined(_MSC_VER))
# if MALLOCDBG == 2
@ -678,6 +678,8 @@ int
main(int argc, char *argv[])
{
int i;
char * lc_ctype;
char * lc_numeric;
char zText[MAX_PATH];
setup_signal_handler();
@ -689,16 +691,18 @@ main(int argc, char *argv[])
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version());
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
lc_ctype = setlocale(LC_CTYPE, "");
lc_numeric = setlocale(LC_NUMERIC, "C");
if (lc_ctype) lc_ctype = strdup(lc_ctype);
if (lc_numeric) lc_numeric = strdup(lc_numeric);
#ifdef LOCALE_CHECK
if (!locale_check()) {
log_error(("The current locale is not suitable for international Eressea.\n"));
return -1;
}
#endif
#ifdef MALLOCDBG
init_malloc_debug();
#ifdef CRTDBG
init_crtdbg();
#endif
lua_State * luaState = lua_init();
@ -739,5 +743,11 @@ main(int argc, char *argv[])
kernel_done();
lua_done(luaState);
log_close();
setlocale(LC_CTYPE, lc_ctype);
setlocale(LC_NUMERIC, lc_numeric);
free(lc_ctype);
free(lc_numeric);
return 0;
}