[Pinfo-devel] r211 - pinfo/branches/cxx/src

Nathanael Nerode neroden-guest at costa.debian.org
Thu Sep 8 12:22:14 UTC 2005


Author: neroden-guest
Date: 2005-09-08 12:22:13 +0000 (Thu, 08 Sep 2005)
New Revision: 211

Modified:
   pinfo/branches/cxx/src/utils.cxx
   pinfo/branches/cxx/src/utils.h
   pinfo/branches/cxx/src/video.cxx
Log:
Eliminate xmalloc/xrealloc/xfree completely.
Also remove redundant call to getmaxyx in video.cxx.
Also remove unused variable i in video.cxx.


Modified: pinfo/branches/cxx/src/utils.cxx
===================================================================
--- pinfo/branches/cxx/src/utils.cxx	2005-09-08 12:14:30 UTC (rev 210)
+++ pinfo/branches/cxx/src/utils.cxx	2005-09-08 12:22:13 UTC (rev 211)
@@ -44,154 +44,13 @@
 #include <readline/history.h>
 #include <term.h>
 
-
-/*
- * the below define enables malloc/realloc/free logging to stderr.
- * They start to log their argument values.
- *
- * #define ___DEBUG___
- *
- */
-
-#ifdef ___DEBUG___
-unsigned long malloc_addr[1000];
-unsigned long msizes[1000];
-long addrescount = 0;
-/* ___DEBUG___ */
-#endif
-
-
 int curses_open = 0;
 
 int shell_cursor = 1;
 
 void
-xfree(void *ptr)
-{
-#ifdef ___DEBUG___
-	int i, j;
-	int flag = 0;
-	unsigned long msize = 0;
-	for (i = 0; i < addrescount; i++)
-		msize += msizes[i];
-	fprintf(stderr, "Size: %lu, count: %ld, freeing %lu\n", msize, addrescount,(unsigned long) ptr);
-	for (i = 0; i < addrescount; i++)
-		if (malloc_addr[i] ==(unsigned long) ptr)
-		{
-			flag = 1;
-			for (j = i + 1; j < addrescount; j++)
-			{
-				malloc_addr[j - 1] = malloc_addr[j];
-				msizes[j - 1] = msizes[j];
-			}
-			addrescount--;
-			break;
-		}
-	if (flag == 0)
-	{
-		fprintf(stderr, "ERROR!!!\n");
-		getchar();
-	}
-/* ___DEBUG___ */
-#endif
-	free(ptr);
-}
-
-void *
-xmalloc(size_t size)
-{
-	register void *value = malloc(size);
-#ifdef ___DEBUG___
-	unsigned long msize = 0;
-	int i;
-/* ___DEBUG___ */
-#endif
-	if (value == 0)
-	{
-		closeprogram();
-		printf(_("Virtual memory exhausted\n"));
-		exit(1);
-	}
-#ifdef ___DEBUG___
-	for (i = 0; i < addrescount; i++)
-		msize += msizes[i];
-	fprintf(stderr, "Size %lu, count: %ld, allocated %lu\n", msize, addrescount,(unsigned long) value);
-	malloc_addr[addrescount] =(unsigned long) value;
-	msizes[addrescount] = size;
-	if (addrescount < 1000)
-		addrescount++;
-	else
-	{
-		fprintf(stderr, "trace buffer exhausted\n");
-	}
-/* ___DEBUG___ */
-#endif
-	memset(value, 0, size);
-	return value;
-}
-
-void *
-xrealloc(void *ptr, size_t size)
-{
-#ifdef ___DEBUG___
-	int i, j, flag = 0;
-	register void *value;
-	unsigned long msize = 0;
-	for (i = 0; i < addrescount; i++)
-		msize += msizes[i];
-	fprintf(stderr, "Size: %lu, count: %ld, reallocating %lu to ", msize, addrescount,(unsigned long) ptr);
-	for (i = 0; i < addrescount; i++)
-		if (malloc_addr[i] ==(unsigned long) ptr)
-		{
-			flag = 1;
-			for (j = i + 1; j < addrescount; j++)
-			{
-				malloc_addr[j - 1] = malloc_addr[j];
-				msizes[j - 1] = msizes[j];
-			}
-			addrescount--;
-			break;
-		}
-	if (flag == 0)
-	{
-		fprintf(stderr, "ERROR!!!\n");
-		getchar();
-	}
-	value = realloc(ptr, size);
-#else
-	register void *value = realloc(ptr, size + 1024);
-/* ___DEBUG___ */
-#endif
-	if (value == 0)
-	{
-		closeprogram();
-		printf(_("Virtual memory exhausted\n"));
-		exit(1);
-	}
-#ifdef ___DEBUG___
-	fprintf(stderr, "%lu, with size %lu\n",(unsigned long) value,(unsigned long) size);
-	malloc_addr[addrescount] =(unsigned long) value;
-	msizes[addrescount] = size;
-	if (addrescount < 1000)
-		addrescount++;
-	else
-	{
-		fprintf(stderr, "trace buffer exhausted\n");
-	}
-/* ___DEBUG___ */
-#endif
-	return value;
-}
-
-void
 initlocale()
 {
-#ifdef ___DEBUG___
-	int i;
-	for (i = 0; i < 1000; i++)
-		malloc_addr[i] = 0;
-/* ___DEBUG___ */
-#endif
 	sbrk(100000);
 	setlocale(LC_ALL, "");
 	bindtextdomain(PACKAGE, LOCALEDIR);
@@ -264,7 +123,7 @@
 		my_string = "";
 	} else {
 		my_string = buf;
-		xfree(buf);
+		free(buf);
 	}
 	return my_string;
 }

Modified: pinfo/branches/cxx/src/utils.h
===================================================================
--- pinfo/branches/cxx/src/utils.h	2005-09-08 12:14:30 UTC (rev 210)
+++ pinfo/branches/cxx/src/utils.h	2005-09-08 12:22:13 UTC (rev 211)
@@ -35,12 +35,6 @@
 
 /* user defined getch, capable of handling ALT keybindings */
 int pinfo_getch ();
-/* free() wrapper */
-void xfree (void *ptr);
-/* malloc() wrapper */
-void *xmalloc (size_t size);
-/* realloc() wrapper */
-void *xrealloc (void *ptr, size_t size);
 /* initializes GNU locales */
 void initlocale ();
 /* bail out if file name causes security problems */

Modified: pinfo/branches/cxx/src/video.cxx
===================================================================
--- pinfo/branches/cxx/src/video.cxx	2005-09-08 12:14:30 UTC (rev 210)
+++ pinfo/branches/cxx/src/video.cxx	2005-09-08 12:22:13 UTC (rev 211)
@@ -73,7 +73,6 @@
 showscreen(const vector <string> message, long pos, long cursor, int column)
 {
 	/* pos is 1-based, message is 0-based */
-	long i;
 #ifdef getmaxyx
 	getmaxyx(stdscr, maxy, maxx);
 #endif
@@ -123,8 +122,6 @@
 void
 info_addstring(int y, string::size_type x, string txt, string::size_type column)
 {
-  int maxy, maxx;
-  getmaxyx(stdscr, maxy, maxx);
   /* Use maxx and mvaddnstr to force clipping.
    * Fairly blunt instrument, but the best I could come up with.
    * Breaks in the presence of tabs; I don't see how to handle them. */




More information about the Pinfo-devel mailing list