summary refs log tree commit diff stats
path: root/src/common/util.c
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-06-21 22:21:12 -0400
committerTingPing <tingping@tingping.se>2014-06-21 22:21:12 -0400
commit45526205abb7ddbf3d21d19b51353d113027118f (patch)
tree566f82d36fe2f80f2eff3f203356c16d9b597e83 /src/common/util.c
parent3342af4185eccba3cf5a9c6e2d2d426911afa0c6 (diff)
Remove broken debug code
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c181
1 files changed, 0 insertions, 181 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 167f8b81..f0438344 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -71,187 +71,6 @@
 #define snprintf g_snprintf
 #endif
 
-#ifdef USE_DEBUG
-
-#undef free
-#undef malloc
-#undef realloc
-#undef strdup
-
-int current_mem_usage;
-
-struct mem_block
-{
-	char *file;
-	void *buf;
-	int size;
-	int line;
-	int total;
-	struct mem_block *next;
-};
-
-struct mem_block *mroot = NULL;
-
-void *
-hexchat_malloc (int size, char *file, int line)
-{
-	void *ret;
-	struct mem_block *new;
-
-	current_mem_usage += size;
-	ret = malloc (size);
-	if (!ret)
-	{
-		printf ("Out of memory! (%d)\n", current_mem_usage);
-		exit (255);
-	}
-
-	new = malloc (sizeof (struct mem_block));
-	new->buf = ret;
-	new->size = size;
-	new->next = mroot;
-	new->line = line;
-	new->file = strdup (file);
-	mroot = new;
-
-	printf ("%s:%d Malloc'ed %d bytes, now \033[35m%d\033[m\n", file, line,
-				size, current_mem_usage);
-
-	return ret;
-}
-
-void *
-hexchat_realloc (char *old, int len, char *file, int line)
-{
-	char *ret;
-
-	ret = hexchat_malloc (len, file, line);
-	if (ret)
-	{
-		strcpy (ret, old);
-		hexchat_dfree (old, file, line);
-	}
-	return ret;
-}
-
-void *
-hexchat_strdup (char *str, char *file, int line)
-{
-	void *ret;
-	struct mem_block *new;
-	int size;
-
-	size = strlen (str) + 1;
-	current_mem_usage += size;
-	ret = malloc (size);
-	if (!ret)
-	{
-		printf ("Out of memory! (%d)\n", current_mem_usage);
-		exit (255);
-	}
-	strcpy (ret, str);
-
-	new = malloc (sizeof (struct mem_block));
-	new->buf = ret;
-	new->size = size;
-	new->next = mroot;
-	new->line = line;
-	new->file = strdup (file);
-	mroot = new;
-
-	printf ("%s:%d strdup (\"%-.40s\") size: %d, total: \033[35m%d\033[m\n",
-				file, line, str, size, current_mem_usage);
-
-	return ret;
-}
-
-void
-hexchat_mem_list (void)
-{
-	struct mem_block *cur, *p;
-	GSList *totals = 0;
-	GSList *list;
-
-	cur = mroot;
-	while (cur)
-	{
-		list = totals;
-		while (list)
-		{
-			p = list->data;
-			if (p->line == cur->line &&
-					strcmp (p->file, cur->file) == 0)
-			{
-				p->total += p->size;
-				break;
-			}
-			list = list->next;
-		}
-		if (!list)
-		{
-			cur->total = cur->size;
-			totals = g_slist_prepend (totals, cur);
-		}
-		cur = cur->next;
-	}
-
-	fprintf (stderr, "file              line   size    num  total\n");  
-	list = totals;
-	while (list)
-	{
-		cur = list->data;
-		fprintf (stderr, "%-15.15s %6d %6d %6d %6d\n", cur->file, cur->line,
-					cur->size, cur->total/cur->size, cur->total);
-		list = list->next;
-	}
-}
-
-void
-hexchat_dfree (void *buf, char *file, int line)
-{
-	struct mem_block *cur, *last;
-
-	if (buf == NULL)
-	{
-		printf ("%s:%d \033[33mTried to free NULL\033[m\n", file, line);
-		return;
-	}
-
-	last = NULL;
-	cur = mroot;
-	while (cur)
-	{
-		if (buf == cur->buf)
-			break;
-		last = cur;
-		cur = cur->next;
-	}
-	if (cur == NULL)
-	{
-		printf ("%s:%d \033[31mTried to free unknown block %lx!\033[m\n",
-				  file, line, (unsigned long) buf);
-		/*      abort(); */
-		free (buf);
-		return;
-	}
-	current_mem_usage -= cur->size;
-	printf ("%s:%d Free'ed %d bytes, usage now \033[35m%d\033[m\n",
-				file, line, cur->size, current_mem_usage);
-	if (last)
-		last->next = cur->next;
-	else
-		mroot = cur->next;
-	free (cur->file);
-	free (cur);
-}
-
-#define malloc(n) hexchat_malloc(n, __FILE__, __LINE__)
-#define realloc(n, m) hexchat_realloc(n, m, __FILE__, __LINE__)
-#define free(n) hexchat_dfree(n, __FILE__, __LINE__)
-#define strdup(n) hexchat_strdup(n, __FILE__, __LINE__)
-
-#endif /* MEMORY_DEBUG */
-
 char *
 file_part (char *file)
 {