diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2012-08-23 15:20:32 +0000 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2012-08-23 15:20:32 +0000 |
commit | 61b8525663fc659daa0321c1dc8f4b3e30e214c7 (patch) | |
tree | a621c6a796ef304350662f93c8b246604b950d87 /Build | |
parent | 35c43cd52fe2bf50e0c8a25a3066865d46fc2bf7 (diff) |
Remove memory debugging code
git-svn-id: svn://tug.org/texlive/trunk@27503 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/xdvipdfmx/ChangeLog.TL | 5 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/dpxfile.c | 8 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/dvipdfmx.c | 4 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/mem.c | 129 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/mem.h | 33 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/xbb.c | 4 |
6 files changed, 11 insertions, 172 deletions
diff --git a/Build/source/texk/xdvipdfmx/ChangeLog.TL b/Build/source/texk/xdvipdfmx/ChangeLog.TL index d0805970de3..2720e67a54d 100644 --- a/Build/source/texk/xdvipdfmx/ChangeLog.TL +++ b/Build/source/texk/xdvipdfmx/ChangeLog.TL @@ -1,6 +1,11 @@ ChangeLog.TL: TeX Live (TL) changes for xdvipdfmx ================================================= +2012-08-23 Khaled Hosny <khaledhosny@eglug.org> + + * src/dvipdfmx.c, src/mem.c, src/mem.h, src/xbb.c, src/dvipdfmx.c, + src/mem.c, src/mem.h, src/xbb.c: Remove memory debugging code. + 2012-08-21 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * src/tt_post.c (read_v2_post_names): support large truetype fonts diff --git a/Build/source/texk/xdvipdfmx/src/dpxfile.c b/Build/source/texk/xdvipdfmx/src/dpxfile.c index 0ee6e437b04..2b5dc1828c5 100644 --- a/Build/source/texk/xdvipdfmx/src/dpxfile.c +++ b/Build/source/texk/xdvipdfmx/src/dpxfile.c @@ -61,8 +61,6 @@ dpx_file_set_verbose (void) } -#define mystrdup(s1) (char *) MEM_ADD(strdup(s1)) - /* Kpathsea library does not check file type. */ static int qcheck_filetype (const char *fqpn, int type); @@ -656,7 +654,7 @@ dpx_find_type1_file (const char *filename) char *fqpn = NULL; if (is_absolute_path(filename)) - fqpn = mystrdup(filename); + fqpn = strdup(filename); else fqpn = kpse_find_file(filename, kpse_type1_format, 0); if (fqpn && !qcheck_filetype(fqpn, DPX_RES_TYPE_T1FONT)) { @@ -674,7 +672,7 @@ dpx_find_truetype_file (const char *filename) char *fqpn = NULL; if (is_absolute_path(filename)) - fqpn = mystrdup(filename); + fqpn = strdup(filename); else fqpn = kpse_find_file(filename, kpse_truetype_format, 0); if (fqpn && !qcheck_filetype(fqpn, DPX_RES_TYPE_TTFONT)) { @@ -695,7 +693,7 @@ dpx_find_opentype_file (const char *filename) q = ensuresuffix(filename, ".otf"); #ifndef MIKTEX if (is_absolute_path(q)) - fqpn = mystrdup(q); + fqpn = strdup(q); else fqpn = kpse_find_file(q, kpse_opentype_format, 0); if (!fqpn) { diff --git a/Build/source/texk/xdvipdfmx/src/dvipdfmx.c b/Build/source/texk/xdvipdfmx/src/dvipdfmx.c index 041605beb39..0ce3e07a96d 100644 --- a/Build/source/texk/xdvipdfmx/src/dvipdfmx.c +++ b/Build/source/texk/xdvipdfmx/src/dvipdfmx.c @@ -833,8 +833,6 @@ main (int argc, char *argv[]) else if (STRN_CMP(av0, "xbb", 3) == 0 || STRN_CMP(av0, "extractbb", 9) == 0) return extractbb(argc, argv, XBB_OUTPUT); - mem_debug_init(); - #ifdef MIKTEX miktex_initialize(); #else @@ -971,7 +969,5 @@ main (int argc, char *argv[]) miktex_uninitialize (); #endif - mem_debug_check(); - return 0; } diff --git a/Build/source/texk/xdvipdfmx/src/mem.c b/Build/source/texk/xdvipdfmx/src/mem.c index b0f02309b0b..33c682c0828 100644 --- a/Build/source/texk/xdvipdfmx/src/mem.c +++ b/Build/source/texk/xdvipdfmx/src/mem.c @@ -29,135 +29,6 @@ #include "mem.h" #include "error.h" -#ifdef MEM_DEBUG - -#include "dpxutil.h" - -#define MEM_LINE 180 - -static struct ht_table *mem_ht; -static long int mem_event; -static int mem_internal; -char *mem_str; - -void mem_debug_init(void) -{ - mem_event = 0; - mem_internal = 0; - mem_ht = malloc(sizeof(struct ht_table)); - ht_init_table(mem_ht); - fprintf(stderr, "*** Memory debugging started ***\n"); -} - -void mem_debug_check(void) -{ - struct ht_iter iter; - - fprintf(stderr, "*** Memory still in use ***\n"); - - if (ht_set_iter(mem_ht, &iter) == 0) { - do { - int pl; - void *p = *((void **) ht_iter_getkey(&iter, &pl)); - char *s = ht_iter_getval(&iter); - - fprintf(stderr, "%p %s\n", p, s); - } while (!ht_iter_next(&iter)); - } - ht_clear_iter(&iter); - - fprintf(stderr, "*** End of used memory ***\n"); -} - -static void -mem_noop (void *vp) -{ -} - -static void -mem_error (void *vp) -{ - ERROR("Internal memory debugging error\n1: %s\n2: %s\n", - vp, (char *) vp, mem_str); -} - -void *mem_add(void *ptr, const char *file, const char *function, int line) { - if (ptr && !mem_internal) { - char **p; - mem_internal = 1; - mem_str = malloc(MEM_LINE); - p = malloc(sizeof(ptr)); - *p = ptr; - snprintf(mem_str, MEM_LINE, "(0x%08lx) %s (%s, %d)" -#ifdef __GNUC__ - ", %p" //" %p" -#endif - , ++mem_event, function, file, line -#ifdef __GNUC__ - , __builtin_return_address(1) //, __builtin_return_address(2) -#endif - ); - ht_insert_table(mem_ht, p, sizeof(ptr), mem_str, mem_error); - mem_internal = 0; - } - - return ptr; -} - -void *mem_remove(void *ptr, const char *file, const char *function, int line) { - if (ptr && !mem_internal) { - mem_internal = 1; - if (!(mem_ht && ht_remove_table(mem_ht, &ptr, sizeof(ptr), mem_noop))) { - WARN("Trying to free non-allocated memory\n" - "%p %s (%s, %d)" -#ifdef __GNUC__ - ", called from %p" -#endif - "\n", ptr, function, file, line -#ifdef __GNUC__ - , __builtin_return_address(1) -#endif - ); - } - mem_internal = 0; - } - - return ptr; -} - - -#else /* ! MEM_DEBUG */ - -static long int mem_count; - -void mem_debug_init(void) -{ - mem_count = 0; -} - -void mem_debug_check(void) -{ - if (mem_count) - WARN("%ld memory objects still allocated\n" - "You may want to report this to tex-k@tug.org\n", mem_count); -} - -void *mem_add(void *ptr) { - if (ptr) - mem_count++; - - return ptr; -} - -void *mem_remove(void *ptr) { - if (ptr) - mem_count--; - - return ptr; -} - -#endif /* MEM_DEBUG */ - void *new (size_t size) { diff --git a/Build/source/texk/xdvipdfmx/src/mem.h b/Build/source/texk/xdvipdfmx/src/mem.h index 852a011e168..263748a5885 100644 --- a/Build/source/texk/xdvipdfmx/src/mem.h +++ b/Build/source/texk/xdvipdfmx/src/mem.h @@ -30,35 +30,8 @@ extern void *new (size_t size); extern void *renew (void *p, size_t size); -extern void mem_debug_init(void); -extern void mem_debug_check(void); - -#ifdef MEM_DEBUG - -extern void *mem_add (void *ptr, - const char *file, const char *function, int line); -extern void *mem_remove (void *ptr, - const char *file, const char *function, int line); -#define MEM_ADD(p) mem_add(p, __FILE__, __FUNCTION__, __LINE__) -#define MEM_REMOVE(p) mem_remove(p, __FILE__, __FUNCTION__, __LINE__) - -#else /* ! MEM_DEBUG */ - -extern void *mem_add (void *ptr); -extern void *mem_remove (void *ptr); -#define MEM_ADD(p) mem_add(p) -#define MEM_REMOVE(p) mem_remove(p) - -#endif /* MEM_DEBUG */ - - -#define NEW(n,type) (type *) MEM_ADD(new(((size_t)(n))*sizeof(type))) -#define RENEW(p,n,type) (type *) MEM_ADD(renew(MEM_REMOVE(p),(n)*sizeof(type))) -#define RELEASE(p) free(MEM_REMOVE(p)) - -/* wrappers for functions from kpathsea */ -#define kpse_path_search(x,y,z) (char *) MEM_ADD(kpse_path_search(x,y,z)) -#define kpse_find_file(x,y,z) (char *) MEM_ADD(kpse_find_file(x,y,z)) -#define kpse_find_glyph(x,y,z,w) (char *) MEM_ADD(kpse_find_glyph(x,y,z,w)) +#define NEW(n,type) (type *) new(((size_t)(n))*sizeof(type)) +#define RENEW(p,n,type) (type *) renew(p,(n)*sizeof(type)) +#define RELEASE(p) free(p) #endif /* _MEM_H_ */ diff --git a/Build/source/texk/xdvipdfmx/src/xbb.c b/Build/source/texk/xdvipdfmx/src/xbb.c index 809fae8e594..199dd5b5403 100644 --- a/Build/source/texk/xdvipdfmx/src/xbb.c +++ b/Build/source/texk/xdvipdfmx/src/xbb.c @@ -432,8 +432,6 @@ static void do_pdf (FILE *fp, char *filename) int extractbb (int argc, char *argv[], int mode) { - mem_debug_init(); - xbb_output_mode = mode; pdf_files_init(); @@ -504,7 +502,5 @@ int extractbb (int argc, char *argv[], int mode) pdf_files_close(); - mem_debug_check(); - return 0; } |