mirror of
https://github.com/moparisthebest/hexchat
synced 2024-12-21 23:28:51 -05:00
Remove broken debug code
This commit is contained in:
parent
3342af4185
commit
45526205ab
@ -1119,10 +1119,6 @@ main (int argc, char *argv[])
|
||||
_SSL_context_free (ctx);
|
||||
#endif
|
||||
|
||||
#ifdef USE_DEBUG
|
||||
hexchat_mem_list ();
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
WSACleanup ();
|
||||
#endif
|
||||
|
@ -44,17 +44,6 @@
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
#ifdef USE_DEBUG
|
||||
#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__)
|
||||
void *hexchat_malloc (int size, char *file, int line);
|
||||
void *hexchat_strdup (char *str, char *file, int line);
|
||||
void hexchat_dfree (void *buf, char *file, int line);
|
||||
void *hexchat_realloc (char *old, int len, char *file, int line);
|
||||
#endif
|
||||
|
||||
#ifdef SOCKS
|
||||
#ifdef __sgi
|
||||
#include <sys/time.h>
|
||||
|
@ -56,9 +56,6 @@
|
||||
#include "outbound.h"
|
||||
#include "chanopt.h"
|
||||
|
||||
#ifdef USE_DEBUG
|
||||
extern int current_mem_usage;
|
||||
#endif
|
||||
#define TBUFSIZE 4096
|
||||
|
||||
static void help (session *sess, char *tbuf, char *helpcmd, int quiet);
|
||||
@ -922,10 +919,6 @@ cmd_debug (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
"current_tab: %p\n\n",
|
||||
sess->server->front_session, current_tab);
|
||||
PrintText (sess, tbuf);
|
||||
#ifdef USE_DEBUG
|
||||
sprintf (tbuf, "current mem: %d\n\n", current_mem_usage);
|
||||
PrintText (sess, tbuf);
|
||||
#endif /* !MEMORY_DEBUG */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user