Branch: Tag:

2000-03-20

2000-03-20 21:00:58 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

faster dmalloc

Rev: src/block_alloc.h:1.16
Rev: src/builtin_functions.c:1.245
Rev: src/dmalloc.h:1.20
Rev: src/dynamic_buffer.h:1.7
Rev: src/error.c:1.42
Rev: src/object.c:1.94
Rev: src/pike_memory.c:1.55
Rev: src/pike_types.h:1.38
Rev: src/stralloc.c:1.80
Rev: src/stralloc.h:1.41
Rev: src/svalue.c:1.63
Rev: src/svalue.h:1.48

1:   /* -  * $Id: dmalloc.h,v 1.19 2000/03/07 21:23:41 hubbe Exp $ +  * $Id: dmalloc.h,v 1.20 2000/03/20 21:00:04 hubbe Exp $    */      extern char *debug_xalloc(long); -  +  + #define DMALLOC_LOCATION() ("S" __FILE__ ":" DEFINETOSTR(__LINE__) ) +    #ifdef DEBUG_MALLOC   struct memhdr;   
14: Inside #if defined(DEBUG_MALLOC)
     extern int verbose_debug_malloc;   extern int verbose_debug_exit; - extern void dmalloc_register(void *, int,const char *, int); + extern void dmalloc_register(void *, int, char *);   extern int dmalloc_unregister(void *, int); - extern void *debug_malloc(size_t, const char *, int); - extern void *debug_calloc(size_t, size_t, const char *, int); - extern void *debug_realloc(void *, size_t, const char *, int); - extern void debug_free(void *, const char *, int,int); - extern char *debug_strdup(const char *, const char *, int); + extern void *debug_malloc(size_t, char *); + extern void *debug_calloc(size_t, size_t, char *); + extern void *debug_realloc(void *, size_t, char *); + extern void debug_free(void *, char *,int); + extern char *debug_strdup(const char *, char *);   extern void reset_debug_malloc(void);   extern void dmalloc_free(void *p); - extern int debug_malloc_touch_fd(int, const char *, int); - extern int debug_malloc_register_fd(int, const char *, int); - extern int debug_malloc_close_fd(int, const char *, int); + extern int debug_malloc_touch_fd(int, char *); + extern int debug_malloc_register_fd(int, char *); + extern int debug_malloc_close_fd(int, char *);    - void *debug_malloc_update_location(void *,const char *, int); + void *debug_malloc_update_location(void *, char *);   void search_all_memheaders_for_references(void);      /* Beware! names of named memory regions are never ever freed!! /Hubbe */ - void *debug_malloc_name(void *p,const char *fn, int line); + void *debug_malloc_name(void *p, char *fn, int line);   void debug_malloc_copy_names(void *p, void *p2);      /* glibc 2.1 defines this as a macro. */
39:   #undef strdup   #endif    - #define malloc(x) debug_malloc((x), __FILE__, __LINE__) - #define calloc(x, y) debug_calloc((x), (y), __FILE__, __LINE__) - #define realloc(x, y) debug_realloc((x), (y), __FILE__, __LINE__) - #define free(x) debug_free((x), __FILE__, __LINE__,0) - #define dmfree(x) debug_free((x),__FILE__,__LINE__,1) - #define strdup(x) debug_strdup((x), __FILE__, __LINE__) + #define malloc(x) debug_malloc((x), DMALLOC_LOCATION()) + #define calloc(x, y) debug_calloc((x), (y), DMALLOC_LOCATION()) + #define realloc(x, y) debug_realloc((x), (y), DMALLOC_LOCATION()) + #define free(x) debug_free((x), DMALLOC_LOCATION(),0) + #define dmfree(x) debug_free((x),DMALLOC_LOCATION(),1) + #define strdup(x) debug_strdup((x), DMALLOC_LOCATION())   #define DO_IF_DMALLOC(X) X - #define debug_malloc_touch(X) debug_malloc_update_location((X),__FILE__,__LINE__) - #define debug_malloc_pass(X) debug_malloc_update_location((X),__FILE__,__LINE__) + #define debug_malloc_touch(X) debug_malloc_update_location((X),DMALLOC_LOCATION()) + #define debug_malloc_pass(X) debug_malloc_update_location((X),DMALLOC_LOCATION())   #define xalloc(X) ((char *)debug_malloc_touch(debug_xalloc(X)))   void debug_malloc_dump_references(void *x); - #define dmalloc_touch(TYPE,X) ((TYPE)debug_malloc_update_location((X),__FILE__,__LINE__)) + #define dmalloc_touch(TYPE,X) ((TYPE)debug_malloc_update_location((X),DMALLOC_LOCATION()))   #define dmalloc_touch_svalue(X) do { struct svalue *_tmp = (X); if ((X)->type <= MAX_REF_TYPE) { debug_malloc_touch(_tmp->u.refs); } } while(0)    - #define DMALLOC_LINE_ARGS ,char * dmalloc_file, int dmalloc_line - #define DMALLOC_POS ,__FILE__,__LINE__ - #define DMALLOC_PROXY_ARGS ,dmalloc_file,dmalloc_line + #define DMALLOC_LINE_ARGS ,char * dmalloc_location + #define DMALLOC_POS ,DMALLOC_LOCATION() + #define DMALLOC_PROXY_ARGS ,dmalloc_location   void dmalloc_accept_leak(void *); - #define dmalloc_touch_fd(X) debug_malloc_touch_fd((X),__FILE__,__LINE__) - #define dmalloc_register_fd(X) debug_malloc_register_fd((X),__FILE__,__LINE__) - #define dmalloc_close_fd(X) debug_malloc_close_fd((X),__FILE__,__LINE__) + #define dmalloc_touch_fd(X) debug_malloc_touch_fd((X),DMALLOC_LOCATION()) + #define dmalloc_register_fd(X) debug_malloc_register_fd((X),DMALLOC_LOCATION()) + #define dmalloc_close_fd(X) debug_malloc_close_fd((X),DMALLOC_LOCATION())   #else   #define dmalloc_touch_fd(X) (X)   #define dmalloc_register_fd(X) (X)