[Scummvm-cvs-logs] SF.net SVN: scummvm:[38385] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Mon Feb 16 23:45:24 CET 2009


Revision: 38385
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38385&view=rev
Author:   thebluegr
Date:     2009-02-16 22:45:23 +0000 (Mon, 16 Feb 2009)

Log Message:
-----------
Removed unused code and defines

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/scriptconsole.cpp
    scummvm/trunk/engines/sci/include/resource.h
    scummvm/trunk/engines/sci/include/sci_memory.h
    scummvm/trunk/engines/sci/scicore/sci_memory.cpp

Modified: scummvm/trunk/engines/sci/engine/scriptconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-02-16 21:57:22 UTC (rev 38384)
+++ scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-02-16 22:45:23 UTC (rev 38385)
@@ -124,105 +124,7 @@
 cmd_param_t *cmd_params;
 
 
-/********** dmalloc functions **********/
-
-#ifdef WITH_DMALLOC
-
-int
-c_dm_stats(state_t * s) {
-	dmalloc_log_stats();
-	return 0;
-}
-
-int
-c_dm_log_unfreed(state_t * s) {
-	dmalloc_log_unfreed();
-	return 0;
-}
-
-int
-c_dm_verify(state_t * s) {
-	unsigned long pointer_var;
-	void *ptr;
-
-	pointer_var = strtoul(cmd_params[0].str, NULL, 0);
-	ptr = (void *) pointer_var;
-
-	dmalloc_verify(ptr);
-
-	return 0;
-}
-
-int
-c_dm_debug(state_t * s) {
-	if (cmd_paramlength) {
-		long newval = strtol(cmd_params[0].str, NULL, 0);
-
-		sciprintf("Setting dmalloc_debug(%ld)\n", newval);
-		dmalloc_debug(newval);
-	} else
-		sciprintf("dmalloc_debug is at 0x%lx\n", dmalloc_debug_current());
-	return 0;
-}
-
-int
-c_dm_mark(state_t * s) {
-	unsigned long mark = dmalloc_mark();
-
-	dmalloc_message("------------- MARK 0x%lx ---------------\n", mark);
-	sciprintf("mark 0x%lx\n", mark);
-	return 0;
-}
-
-int
-c_dm_chmark(state_t * s) {
-	unsigned long mark = strtoul(cmd_params[0].str, NULL, 0);
-	sciprintf("Checking mark 0x%lx\n", mark);
-	dmalloc_message("--- Mark 0x%lx:\n", mark);
-	dmalloc_log_changed(mark, 1, 1, 1);
-	return 0;
-}
-
-int
-c_dm_print(state_t * s) {
-	int i;
-	for (i = 0; i < cmd_paramlength; i++)
-		dmalloc_message("%s\n", cmd_params[i].str);
-	return 0;
-}
-
 void
-con_init_dmalloc() {
-	con_hook_command(c_dm_stats, "dm_stats", "",
-	                 "Prints memory usage stats\n  to the dmalloc output file\n\n  dm_stats");
-	con_hook_command(c_dm_log_unfreed, "dm_log_unfreed", "",
-	                 "Prints unfreed pointer\n  information to the dmalloc\n  output file\n\n"
-	                 "USAGE\n\n  dm_log_unfreed");
-	con_hook_command(c_dm_verify, "dm_verify", "s",
-	                 "Verifies one pointer,\n  prints output to dmalloc file\n\nUSAGE\n\n"
-	                 "  dm_verify <ptr>\n  dm_verify 0\n\n  'dm_verify 0' will verify\n  ALL current pointers.\n");
-	con_hook_command(c_dm_debug, "dm_debug", "s*",
-	                 "Sets the dmalloc debug\n  state or displays it\n\nUSAGE\n\n  dm_debug <mode>\n  dm_debug");
-	con_hook_command(c_dm_mark, "dm_mark", "",
-	                 "Gets a mark describing\n  the current heap state\n\nUSAGE\n\n  dm_mark\n\n"
-	                 "  The mark is written to the\n  dmalloc output file and\n  to sci output.\n\nSEE ALSO\n\n  cm_chmark");
-	con_hook_command(c_dm_chmark, "dm_chmark", "s",
-	                 "Checks changes in the\n  heap state since a certain\n  mark was retrieved\n\n"
-	                 "USAGE\n\n  c_dm_chmark <mark>\n\n  Output is written to the\n  dmalloc output file.\n\n  Use dm_mark to retrieve a\n"
-	                 "  mark.\n\nSEE ALSO\n\n  c_dm_mark");
-	con_hook_command(c_dm_print, "dm_print", "s*",
-	                 "Prints something to the\n  dmalloc output.\n\nUSAGE\n\n  dm_print <text>");
-}
-#else /* WITH_DMALLOC */
-
-void
-con_init_dmalloc(void) {
-}
-
-#endif /* WITH_DMALLOC */
-
-
-void
 _cmd_exit(void) {
 	int t;
 
@@ -320,8 +222,6 @@
 		              "    ?obj.idx may be used to disambiguate 'obj'\n"
 		              "    by the index 'idx'.\n");
 
-		con_init_dmalloc();
-
 		con_hook_int(&con_passthrough, "con_passthrough",
 		             "scicon->stdout passthrough");
 	}

Modified: scummvm/trunk/engines/sci/include/resource.h
===================================================================
--- scummvm/trunk/engines/sci/include/resource.h	2009-02-16 21:57:22 UTC (rev 38384)
+++ scummvm/trunk/engines/sci/include/resource.h	2009-02-16 22:45:23 UTC (rev 38385)
@@ -55,13 +55,9 @@
 
 /*#define _SCI_RESOURCE_DEBUG */
 /*#define _SCI_DECOMPRESS_DEBUG*/
-#ifndef WITH_DMALLOC
-#  define SCI_SAFE_ALLOC /* Undefine for debugging */
-#endif
 
 //TODO: Remove these defines by replacing their functionality by their ScummVM counterparts
 #define HAVE_MEMCHR
-#define HAVE_UNLINK
 #define HAVE_RMDIR
 #define HAVE_FCNTL_H
 #ifndef _MSC_VER
@@ -352,11 +348,7 @@
 whether a string is really a string or an array. */
 int is_print_str(char *str);
 
-#ifdef HAVE_UNLINK
 #  define sci_unlink unlink
-#else  /* !HAVE_UNLINK */
-#  error "Please provide an int sci_unlink(const char *) for removing filesystem entries"
-#endif /* !HAVE_UNLINK */
 
 #ifdef HAVE_RMDIR
 #  define sci_rmdir rmdir

Modified: scummvm/trunk/engines/sci/include/sci_memory.h
===================================================================
--- scummvm/trunk/engines/sci/include/sci_memory.h	2009-02-16 21:57:22 UTC (rev 38384)
+++ scummvm/trunk/engines/sci/include/sci_memory.h	2009-02-16 22:45:23 UTC (rev 38385)
@@ -38,24 +38,8 @@
  ** Implementations of basic functions found here are in this file and
  ** $(SRCDIR)/src/scicore/sci_memory.c
  *
- * Usage notes:
  **************
  *
- * Define MALLOC_DEBUG to output debug information whenever a memory
- * allocation function is called.
- *
- * Make sure you #define it before any #includes.
- *
- * #define MALLOC_DEBUG
- * #include <...>
- *
- **************
- *
- * Define WITH_DMALLOC to use the dmalloc debug library, available from
- * http://dmalloc.com/
- *
- **************
- *
  * Sets behaviour if memory allocation call fails.
  * UNCHECKED_MALLOCS:  use C library routine without checks
  * (nothing defined):  check mallocs and exit immediately on fail (recommended)
@@ -95,11 +79,6 @@
 /*
  * Called if memory allocation fails.
  */
-#ifdef WITH_DMALLOC
-#	ifdef __unix__
-#		define DISABLE_SCI_MEMORY /* Use malloc() and friends */
-#	endif
-#endif
 #define PANIC_MEMORY(size, filename, linenum, funcname, more_info)\
 	PANIC((stderr, "Memory allocation of %lu bytes failed\n"\
 		" [%s (%s) : %u]\n " #more_info "\n",\
@@ -288,16 +267,6 @@
 
 /********** macro definitions for routines **********/
 
-#ifdef DISABLE_SCI_MEMORY
-#	define sci_malloc malloc
-#	define sci_calloc calloc
-#	define sci_realloc realloc
-#	define sci_free free
-#	define sci_strdup strdup
-#	define sci_strndup strndup
-#	define sci_memdup memdup
-#else
-
 #	ifdef __GNUC__
 #		define sci_malloc(size)\
 			_SCI_MALLOC(size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
@@ -358,7 +327,6 @@
 #		define sci_strndup(src, length)\
 			_SCI_STRNDUP(src, length, __FILE__, __LINE__, "")
 #	endif
-#endif
 
 
 /********** other memory/debug related routines **********/

Modified: scummvm/trunk/engines/sci/scicore/sci_memory.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/sci_memory.cpp	2009-02-16 21:57:22 UTC (rev 38384)
+++ scummvm/trunk/engines/sci/scicore/sci_memory.cpp	2009-02-16 22:45:23 UTC (rev 38385)
@@ -36,8 +36,6 @@
 #include "sci/include/sci_memory.h"
 #include "common/util.h"
 
-/*#define POISON_MEMORY*/
-
 /* set optimisations for Win32: */
 /* g on: enable global optimizations */
 /* t on: use fast code */
@@ -57,15 +55,7 @@
 void *
 _SCI_MALLOC(size_t size, const char *file, int line, const char *funct) {
 	void *res;
-#ifdef MALLOC_DEBUG
-	INFO_MEMORY("_SCI_MALLOC()", size, file, line, funct);
-#endif
 	ALLOC_MEM((res = malloc(size)), size, file, line, funct)
-#ifdef POISON_MEMORY
-	{
-		memset(res, 0xa5, size);
-	}
-#endif
 	return res;
 }
 
@@ -73,9 +63,6 @@
 void *
 _SCI_CALLOC(size_t num, size_t size, const char *file, int line, const char *funct) {
 	void *res;
-#ifdef MALLOC_DEBUG
-	INFO_MEMORY("_SCI_CALLOC()", size, file, line, funct);
-#endif
 	ALLOC_MEM((res = calloc(num, size)), num * size, file, line, funct)
 	return res;
 }
@@ -84,9 +71,6 @@
 void *
 _SCI_REALLOC(void *ptr, size_t size, const char *file, int line, const char *funct) {
 	void *res;
-#ifdef MALLOC_DEBUG
-	INFO_MEMORY("_SCI_REALLOC()", size, file, line, funct);
-#endif
 	ALLOC_MEM((res = realloc(ptr, size)), size, file, line, funct)
 	return res;
 }
@@ -94,9 +78,6 @@
 
 void
 _SCI_FREE(void *ptr, const char *file, int line, const char *funct) {
-#ifdef MALLOC_DEBUG
-	INFO_MEMORY("_SCI_FREE()", 0, file, line, funct);
-#endif
 	if (!ptr) {
 		fprintf(stderr, "_SCI_FREE() [%s (%s) : %u]\n",
 		        file, funct, line);
@@ -110,9 +91,6 @@
 void *
 _SCI_MEMDUP(const void *ptr, size_t size, const char *file, int line, const char *funct) {
 	void *res;
-#ifdef MALLOC_DEBUG
-	INFO_MEMORY("_SCI_MEMDUP()", size, file, line, funct);
-#endif
 	if (!ptr) {
 		fprintf(stderr, "_SCI_MEMDUP() [%s (%s) : %u]\n",
 		        file, funct, line);
@@ -128,9 +106,6 @@
 char *
 _SCI_STRDUP(const char *src, const char *file, int line, const char *funct) {
 	void *res;
-#ifdef MALLOC_DEBUG
-	INFO_MEMORY("_SCI_STRDUP()", 0, file, line, funct);
-#endif
 	if (!src) {
 		fprintf(stderr, "_SCI_STRDUP() [%s (%s) : %u]\n",
 		        file, funct, line);
@@ -147,9 +122,6 @@
 	void *res;
 	char *strres;
 	size_t rlen = (int)MIN(strlen(src), length) + 1;
-#ifdef MALLOC_DEBUG
-	INFO_MEMORY("_SCI_STRNDUP()", 0, file, line, funct);
-#endif
 	if (!src) {
 		fprintf(stderr, "_SCI_STRNDUP() [%s (%s) : %u]\n",
 		        file, funct, line);
@@ -179,10 +151,8 @@
 	        "WARNING: Cannot debug Win32 memory in this mode.\n");
 #else
 
-	int tmpFlag;
+	int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
 
-	tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
-
 	if (dbg_setting > 0)
 		tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF;
 	/* call _CrtCheckMemory at every request */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list