svnno****@sourc*****
svnno****@sourc*****
2010年 11月 29日 (月) 01:32:31 JST
Revision: 335 http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=335 Author: yoya Date: 2010-11-29 01:32:31 +0900 (Mon, 29 Nov 2010) Log Message: ----------- strdup_debug を追加 Modified Paths: -------------- trunk/src/swf_debug.c trunk/src/swf_define.h -------------- next part -------------- Modified: trunk/src/swf_debug.c =================================================================== --- trunk/src/swf_debug.c 2010-11-28 13:48:38 UTC (rev 334) +++ trunk/src/swf_debug.c 2010-11-28 16:32:31 UTC (rev 335) @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> // #include "swf_define.h" no include @@ -50,6 +51,7 @@ } return ptr; } + void * malloc_debug(size_t size, char *filename, int linenum) { int i; @@ -69,6 +71,25 @@ return ptr; } +void * +strdup_debug(const char *s, char *filename, int linenum) { + int i; + void *ptr; + ptr = strdup(s); +// fprintf(stderr, "strdup_debug: ptr=%p (%s,%d)\n", ptr, filename, linenum); + for (i=0 ; i < MALLOC_DEBUG_TABLE_NUM ; i++) { + if (malloc_debug_table[i].ptr == NULL) { + malloc_debug_table[i].ptr = ptr; + malloc_debug_table[i].filename = filename; + malloc_debug_table[i].linenum = linenum; +// fprintf(stderr, "(%d)\n", i); + return ptr; + } + } + fprintf(stderr, "strdup: table full... ;_;\n"); + return ptr; +} + void free_debug(void *ptr, char *filename, int linenum) { int i; Modified: trunk/src/swf_define.h =================================================================== --- trunk/src/swf_define.h 2010-11-28 13:48:38 UTC (rev 334) +++ trunk/src/swf_define.h 2010-11-28 16:32:31 UTC (rev 335) @@ -32,6 +32,7 @@ #define malloc(s) malloc_debug(s,__FILE__,__LINE__) #define free(p) free_debug(p,__FILE__,__LINE__) #define realloc(p,s) realloc_debug(p,s,__FILE__,__LINE__) +#define strdup(s) strdup_debug(s,__FILE__,__LINE__) extern void print_hexbin(unsigned char *data, int data_len);