summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acconfig.h1
-rw-r--r--configure.in22
-rw-r--r--src/common.h2
-rw-r--r--src/core/memdebug.c379
-rw-r--r--src/core/memdebug.h38
-rw-r--r--src/fe-text/irssi.c4
-rw-r--r--src/lib-config/parse.c4
7 files changed, 0 insertions, 450 deletions
diff --git a/acconfig.h b/acconfig.h
index d7d1dfea..33f02000 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -4,7 +4,6 @@
#undef PLUGINSDIR
/* misc.. */
-#undef MEM_DEBUG
#undef HAVE_IPV6
#undef HAVE_POPT_H
#undef HAVE_SOCKS_H
diff --git a/configure.in b/configure.in
index 3116ac2b..7d60a5b8 100644
--- a/configure.in
+++ b/configure.in
@@ -185,19 +185,6 @@ AC_ARG_WITH(tests,
TEST_DIR=)
AC_SUBST(TEST_DIR)
-AC_ARG_ENABLE(memdebug,
-[ --enable-memdebug Enable memory debugging],
- if test x$enableval = xyes; then
- want_memdebug=yes
- else
- if test "x$enableval" = xno; then
- want_memdebug=no
- else
- want_memdebug=yes
- fi
- fi,
- want_memdebug=no)
-
AC_ARG_ENABLE(ipv6,
[ --enable-ipv6 Enable IPv6 support],
if test x$enableval = xyes; then
@@ -730,15 +717,6 @@ AC_SUBST(COMMON_NOUI_LIBS)
AC_SUBST(COMMON_LIBS)
dnl **
-dnl ** memory debugging
-dnl **
-
-if test "x$want_memdebug" = "xyes"; then
- AC_DEFINE(MEM_DEBUG)
-fi
-AM_CONDITIONAL(BUILD_MEMDEBUG, test "x$want_memdebug" = "xyes")
-
-dnl **
dnl ** tr-Chinese Big5 support
dnl **
diff --git a/src/common.h b/src/common.h
index 89d4da94..968c1cd4 100644
--- a/src/common.h
+++ b/src/common.h
@@ -46,8 +46,6 @@
# include <gmodule.h>
#endif
-#include "core/memdebug.h"
-
/* input functions */
#define G_INPUT_READ (1 << 0)
#define G_INPUT_WRITE (1 << 1)
diff --git a/src/core/memdebug.c b/src/core/memdebug.c
deleted file mode 100644
index 213d4542..00000000
--- a/src/core/memdebug.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- memdebug.c : irssi
-
- Copyright (C) 1999-2000 Timo Sirainen
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-#include <gmodule.h>
-
-/*#define ENABLE_BUFFER_CHECKS*/
-#define BUFFER_CHECK_SIZE 5
-#define MIN_BUFFER_CHECK_SIZE 2
-
-typedef struct {
- void *p;
- int size;
- char *file;
- int line;
- char *comment;
-} MEM_REC;
-
-static GHashTable *data = NULL, *preallocs = NULL;
-static const char *comment = "";
-
-static void add_flow_checks(char *p, unsigned long size)
-{
-#ifdef ENABLE_BUFFER_CHECKS
- int n;
-
- for (n = 0; n < BUFFER_CHECK_SIZE; n++)
- p[n] = n ^ 0x7f;
- for (n = 0; n < BUFFER_CHECK_SIZE; n++)
- p[size-BUFFER_CHECK_SIZE+n] = n ^ 0x7f;
-#endif
-}
-
-void ig_memcheck_rec(void *key, MEM_REC *rec)
-{
- guchar *p;
- int n;
-
- if (rec->size != INT_MIN){
- p = rec->p;
-
- for (n = 0; n < MIN_BUFFER_CHECK_SIZE; n++)
- if (p[n] != (n ^ 0x7f))
- g_error("buffer underflow, file %s line %d!\n", rec->file, rec->line);
-
- for (n = 0; n < MIN_BUFFER_CHECK_SIZE; n++)
- if (p[rec->size-BUFFER_CHECK_SIZE+n] != (n ^ 0x7f))
- g_error("buffer overflow, file %s line %d!\n", rec->file, rec->line);
- }
-}
-
-static void mem_check(void)
-{
-#ifdef ENABLE_BUFFER_CHECKS
- g_hash_table_foreach(data, (GHFunc) ig_memcheck_rec, NULL);
-#endif
-}
-
-static void data_add(char *p, int size, const char *file, int line)
-{
- MEM_REC *rec;
-
- if (size <= 0 && size != INT_MIN)
- g_error("size = %d, file %s line %d", size, file, line);
-
- if (data == NULL) {
- data = g_hash_table_new((GHashFunc) g_direct_hash, (GCompareFunc) g_direct_equal);
- preallocs = g_hash_table_new((GHashFunc) g_direct_hash, (GCompareFunc) g_direct_equal);
- }
-
- if (g_hash_table_lookup(data, p) != NULL)
- g_error("data_add() already malloc()'ed %p (in %s:%d)", p, file, line);
-
- rec = g_new(MEM_REC, 1);
- g_hash_table_insert(data, p, rec);
-
- rec->p = p;
- rec->size = size;
- rec->file = g_strdup(file);
- rec->line = line;
- rec->comment = g_strdup(comment);
-
- if (size == INT_MIN)
- g_hash_table_insert(preallocs, p-BUFFER_CHECK_SIZE, p);
- else
- add_flow_checks(p, size);
- mem_check();
-}
-
-static void data_clear(char *p)
-{
- MEM_REC *rec;
-
- if (g_hash_table_lookup(preallocs, p) != NULL)
- p += BUFFER_CHECK_SIZE;
-
- rec = g_hash_table_lookup(data, p);
- if (rec != NULL && rec->size > 0)
- memset(p, 'F', rec->size);
-}
-
-static void *data_remove(char *p, const char *file, int line)
-{
- MEM_REC *rec;
-
- mem_check();
-
- if (g_hash_table_lookup(preallocs, p) != NULL) {
- g_hash_table_remove(preallocs, p);
- p += BUFFER_CHECK_SIZE;
- }
-
- rec = g_hash_table_lookup(data, p);
- if (rec == NULL) {
- g_warning("data_remove() data %p not found (in %s:%d)", p, file, line);
- return p+BUFFER_CHECK_SIZE;
- }
-
- g_hash_table_remove(data, p);
- g_free(rec->file);
- g_free(rec->comment);
- g_free(rec);
-
- return p;
-}
-
-void *ig_malloc(int size, const char *file, int line)
-{
- char *p;
-
- size += BUFFER_CHECK_SIZE*2;
- p = g_malloc(size);
- data_add(p, size, file, line);
- return (void *) (p+BUFFER_CHECK_SIZE);
-}
-
-void *ig_malloc0(int size, const char *file, int line)
-{
- char *p;
-
- size += BUFFER_CHECK_SIZE*2;
- p = g_malloc0(size);
- data_add(p, size, file, line);
- return (void *) (p+BUFFER_CHECK_SIZE);
-}
-
-void *ig_realloc(void *mem, unsigned long size, const char *file, int line)
-{
- char *p, *oldmem = mem;
-
- size += BUFFER_CHECK_SIZE*2;
- oldmem -= BUFFER_CHECK_SIZE;
- data_remove(oldmem, file, line);
- p = g_realloc(oldmem, size);
- data_add(p, size, file, line);
- return (void *) (p+BUFFER_CHECK_SIZE);
-}
-
-char *ig_strdup(const char *str, const char *file, int line)
-{
- void *p;
-
- if (str == NULL) return NULL;
-
- p = ig_malloc(strlen(str)+1, file, line);
- strcpy(p, str);
-
- return p;
-}
-
-char *ig_strndup(const char *str, int count, const char *file, int line)
-{
- char *p;
-
- if (str == NULL) return NULL;
-
- p = ig_malloc(count+1, file, line);
- strncpy(p, str, count); p[count] = '\0';
-
- return p;
-}
-
-char *ig_strconcat(const char *file, int line, const char *str, ...)
-{
- guint l;
- va_list args;
- char *s;
- char *concat;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- l = 1 + strlen (str);
- va_start (args, str);
- s = va_arg (args, char*);
- while (s)
- {
- l += strlen (s);
- s = va_arg (args, char*);
- }
- va_end (args);
-
- concat = ig_malloc(l, file, line);
- concat[0] = 0;
-
- strcat (concat, str);
- va_start (args, str);
- s = va_arg (args, char*);
- while (s)
- {
- strcat (concat, s);
- s = va_arg (args, char*);
- }
- va_end (args);
-
- return concat;
-}
-
-char *ig_strdup_printf(const char *file, int line, const char *format, ...)
-{
- char *buffer, *p;
- va_list args;
-
- va_start (args, format);
- buffer = g_strdup_vprintf (format, args);
- va_end (args);
-
- p = ig_malloc(strlen(buffer)+1, file, line);
- strcpy(p, buffer);
- g_free(buffer);
-
- return p;
-}
-
-char *ig_strdup_vprintf(const char *file, int line, const char *format, va_list args)
-{
- char *buffer, *p;
-
- buffer = g_strdup_vprintf (format, args);
-
- p = ig_malloc(strlen(buffer)+1, file, line);
- strcpy(p, buffer);
- g_free(buffer);
-
- return p;
-}
-
-void ig_free(void *p)
-{
- char *cp = p;
-
- if (cp == NULL) g_error("ig_free() : trying to free NULL");
-
- cp -= BUFFER_CHECK_SIZE;
- data_clear(cp);
- cp = data_remove(cp, "??", 0);
- if (cp != NULL) g_free(cp);
-}
-
-GString *ig_string_new(const char *file, int line, const char *str)
-{
- GString *ret;
-
- ret = g_string_new(str);
- data_add((void *) ret, INT_MIN, file, line);
- return ret;
-}
-
-void ig_string_free(const char *file, int line, GString *str, gboolean freeit)
-{
- data_remove((void *) str, file, line);
- if (!freeit)
- data_add(str->str, INT_MIN, file, line);
-
- g_string_free(str, freeit);
-}
-
-char *ig_strjoinv(const char *file, int line, const char *sepa, char **array)
-{
- char *ret;
-
- ret = g_strjoinv(sepa, array);
- data_add(ret, INT_MIN, file, line);
- return ret;
-}
-
-char *ig_dirname(const char *file, int line, const char *fname)
-{
- char *ret;
-
- ret = g_dirname(fname);
- data_add(ret, INT_MIN, file, line);
- return ret;
-}
-
-char *ig_module_build_path(const char *file, int line, const char *dir, const char *module)
-{
- char *ret;
-
- ret = g_module_build_path(dir, module);
- data_add(ret, INT_MIN, file, line);
- return ret;
-}
-
-void ig_profile_line(void *key, MEM_REC *rec)
-{
- char *data;
-
- if (*rec->comment == '\0' &&
- (strcmp(rec->file, "ig_strdup_printf") == 0 ||
- strcmp(rec->file, "ig_strdup_vprintf") == 0 ||
- strcmp(rec->file, "ig_strconcat") == 0 ||
- strcmp(rec->file, "ig_string_free (free = FALSE)") == 0))
- data = (char *) rec->p + BUFFER_CHECK_SIZE;
- else
- data = rec->comment;
- fprintf(stderr, "%s:%d %d bytes (%s)\n", rec->file, rec->line, rec->size, data);
-}
-
-void ig_mem_profile(void)
-{
- g_hash_table_foreach(data, (GHFunc) ig_profile_line, NULL);
- g_hash_table_destroy(data);
- g_hash_table_destroy(preallocs);
-}
-
-static MEM_REC *largest[10];
-
-void ig_profile_largest(void *key, MEM_REC *rec)
-{
- int n;
-
- for (n = 0; n < 10; n++)
- {
- if (largest[n] == NULL || rec->size > largest[n]->size)
- {
- g_memmove(largest+n+1, largest+n, sizeof(void *)*(9-n));
- largest[n] = rec;
- }
- }
-}
-
-void ig_mem_profile_largest(void)
-{
- /*int n;*/
-
- memset(&largest, 0, sizeof(MEM_REC*)*10);
- /*g_hash_table_foreach(data, (GHFunc) ig_profile_largest, NULL);
-
- for (n = 0; n < 10 && largest[n] != NULL; n++)
- {
- ig_profile_line(NULL, largest[n]);
- }*/
-}
-
-void ig_set_data(const char *data)
-{
- comment = data;
-}
diff --git a/src/core/memdebug.h b/src/core/memdebug.h
deleted file mode 100644
index 3f328805..00000000
--- a/src/core/memdebug.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifdef MEM_DEBUG
-void ig_mem_profile(void);
-
-void ig_set_data(const char *data);
-
-void *ig_malloc(int size, const char *file, int line);
-void *ig_malloc0(int size, const char *file, int line);
-void *ig_realloc(void *mem, unsigned long size, const char *file, int line);
-char *ig_strdup(const char *str, const char *file, int line);
-char *ig_strndup(const char *str, int count, const char *file, int line);
-char *ig_strconcat(const char *file, int line, const char *str, ...);
-char *ig_strdup_printf(const char *file, int line, const char *format, ...) G_GNUC_PRINTF (3, 4);
-char *ig_strdup_vprintf(const char *file, int line, const char *format, va_list args);
-void ig_free(void *p);
-GString *ig_string_new(const char *file, int line, const char *str);
-void ig_string_free(const char *file, int line, GString *str, int freeit);
-char *ig_strjoinv(const char *file, int line, const char *sepa, char **array);
-char *ig_dirname(const char *file, int line, const char *fname);
-char *ig_module_build_path(const char *file, int line, const char *dir, const char *module);
-
-#define g_malloc(a) ig_malloc(a, __FILE__, __LINE__)
-#define g_malloc0(a) ig_malloc0(a, __FILE__, __LINE__)
-#define g_free ig_free
-#define g_realloc(a,b) ig_realloc(a, b, __FILE__, __LINE__)
-#define g_strdup(a) ig_strdup(a, __FILE__, __LINE__)
-#define g_strndup(a, b) ig_strndup(a, b, __FILE__, __LINE__)
-#define g_string_new(a) ig_string_new(__FILE__, __LINE__, a)
-#define g_string_free(a, b) ig_string_free(__FILE__, __LINE__, a, b)
-#define g_strjoinv(a,b) ig_strjoinv(__FILE__, __LINE__, a, b)
-#define g_dirname(a) ig_dirname(__FILE__, __LINE__, a)
-#define g_module_build_path(a, b) ig_module_build_path(__FILE__, __LINE__, a, b)
-
-#ifndef __STRICT_ANSI__
-#define g_strconcat(a...) ig_strconcat(__FILE__, __LINE__, ##a)
-#define g_strdup_printf(a, b...) ig_strdup_printf(__FILE__, __LINE__, a, ##b)
-#define g_strdup_vprintf(a, b...) ig_strdup_vprintf(__FILE__, __LINE__, a, ##b)
-#endif
-#endif
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c
index f08e15de..39ae0ec6 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -324,9 +324,5 @@ int main(int argc, char **argv)
g_main_destroy(main_loop);
textui_deinit();
-#ifdef MEM_DEBUG
- ig_mem_profile();
-#endif
-
return 0;
}
diff --git a/src/lib-config/parse.c b/src/lib-config/parse.c
index 883a920b..a97c6b09 100644
--- a/src/lib-config/parse.c
+++ b/src/lib-config/parse.c
@@ -82,11 +82,7 @@ static void config_parse_get_token(GScanner *scanner, CONFIG_NODE *node)
} else {
if (scanner->token == G_TOKEN_INT) {
scanner->token = G_TOKEN_STRING;
-#undef g_strdup_printf /* This is free'd by GLib itself */
scanner->value.v_string = g_strdup_printf("%lu", scanner->value.v_int);
-#ifdef MEM_DEBUG
-#define g_strdup_printf(a, b...) ig_strdup_printf(__FILE__, __LINE__, a, ##b)
-#endif
}
break;
}