diff --git a/src/dmalloc.h b/src/dmalloc.h
index 082d6369d471015d7e93f36f0f0adecca470b626..e37124959219bd779971db2103428ca1b92b9b60 100644
--- a/src/dmalloc.h
+++ b/src/dmalloc.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: dmalloc.h,v 1.43 2003/02/21 17:27:38 mast Exp $
+|| $Id: dmalloc.h,v 1.44 2003/03/14 15:43:22 grubba Exp $
 */
 
 PMOD_EXPORT extern void *debug_xalloc(size_t);
@@ -11,7 +11,10 @@ PMOD_EXPORT extern void *debug_xmalloc(size_t);
 PMOD_EXPORT extern void *debug_xcalloc(size_t,size_t);
 PMOD_EXPORT extern void *debug_xrealloc(void *,size_t);
 
-#define DMALLOC_LOCATION() (("NS"  __FILE__ ":" DEFINETOSTR(__LINE__) )+1)
+#define DMALLOC_NAMED_LOCATION(NAME)	\
+    (("NS" __FILE__ ":" DEFINETOSTR(__LINE__) NAME )+1)
+
+#define DMALLOC_LOCATION() DMALLOC_NAMED_LOCATION("")
 
 #ifdef DMALLOC_TRACE
 #define DMALLOC_TRACELOGSIZE 131072
@@ -66,20 +69,20 @@ char *dmalloc_find_name(void *p);
 #undef strdup
 #endif
 
-#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 malloc(x) debug_malloc((x), DMALLOC_NAMED_LOCATION(" malloc"))
+#define calloc(x, y) debug_calloc((x), (y), DMALLOC_NAMED_LOCATION(" calloc"))
+#define realloc(x, y) debug_realloc((x), (y), DMALLOC_NAMED_LOCATION(" realloc"))
+#define free(x) debug_free((x), DMALLOC_NAMED_LOCATION(" free"),0)
+#define dmfree(x) debug_free((x),DMALLOC_NAMED_LOCATION(" free"),1)
+#define strdup(x) debug_strdup((x), DMALLOC_NAMED_LOCATION(" strdup"))
 #define DO_IF_DMALLOC(X) X
 #define DO_IF_NOT_DMALLOC(X)
 #define debug_malloc_touch(X) debug_malloc_update_location((void *)(X),DMALLOC_LOCATION())
 #define debug_malloc_pass(X) debug_malloc_update_location((void *)(X),DMALLOC_LOCATION())
 #define dmalloc_touch_struct_ptr(TYPE,X,MEMBER) ((TYPE)debug_malloc_update_location_ptr((void *)(X), ((ptrdiff_t)& (((TYPE)0)->MEMBER)), DMALLOC_LOCATION()))
 
-#define xalloc(X) ((void *)debug_malloc_pass(debug_xalloc(X)))
-#define xfree(X) debug_xfree(debug_malloc_pass((X)))
+#define xalloc(X) ((void *)debug_malloc_update_location((void *)debug_xalloc(X), DMALLOC_NAMED_LOCATION(" xalloc")))
+#define xfree(X) debug_xfree(debug_malloc_update_location((X), DMALLOC_NAMED_LOCATION(" free")))
 void debug_malloc_dump_references(void *x, int indent, int depth, int flags);
 #define dmalloc_touch(TYPE,X) ((TYPE)debug_malloc_update_location((void *)(X),DMALLOC_LOCATION()))
 void debug_malloc_dump_fd(int fd);
diff --git a/src/svalue.h b/src/svalue.h
index d3db8d6d574576ae5f37b903422e69c66aee3159..4d6d5362681391a2204fc30f6be6971933bdc43c 100644
--- a/src/svalue.h
+++ b/src/svalue.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: svalue.h,v 1.116 2003/02/16 03:59:58 mast Exp $
+|| $Id: svalue.h,v 1.117 2003/03/14 15:43:22 grubba Exp $
 */
 
 #ifndef SVALUE_H
@@ -371,11 +371,11 @@ static inline union anything *dmalloc_check_union(union anything *u,int type, ch
 #undef sub_ref
 
 #ifdef PIKE_RUN_UNLOCKED
-#define add_ref(X) pike_atomic_inc32((INT32 *)debug_malloc_pass( &((X)->refs)))
-#define sub_ref(X) pike_atomic_dec_and_test32((INT32 *)debug_malloc_pass( &((X)->refs)))
+#define add_ref(X) pike_atomic_inc32((INT32 *)debug_malloc_update_location( &((X)->refs), DMALLOC_NAMED_LOCATION(" add_ref")))
+#define sub_ref(X) pike_atomic_dec_and_test32((INT32 *)debug_malloc_update_location( &((X)->refs), DMALLOC_NAMED_LOCATION(" sub_ref")))
 #else
-#define add_ref(X) (((INT32 *)debug_malloc_pass( &((X)->refs)))[0]++)
-#define sub_ref(X) (--((INT32 *)debug_malloc_pass( &((X)->refs)))[0] > 0)
+#define add_ref(X) (((INT32 *)debug_malloc_update_location( &((X)->refs), DMALLOC_NAMED_LOCATION(" add_ref")))[0]++)
+#define sub_ref(X) (--((INT32 *)debug_malloc_update_location( &((X)->refs), DMALLOC_NAMED_LOCATION(" sub_ref")))[0] > 0)
 #endif
 
 
@@ -485,7 +485,7 @@ extern struct svalue dest_ob_zero;
 }while(0);
 
 #ifdef DEBUG_MALLOC
-#define free_svalues(X,Y,Z) debug_free_svalues((X),(Y),(Z), DMALLOC_LOCATION());
+#define free_svalues(X,Y,Z) debug_free_svalues((X),(Y),(Z), DMALLOC_NAMED_LOCATION(" free_svalues"));
 #else
 #define free_svalues(X,Y,Z) debug_free_svalues((X),(Y),(Z));
 #endif
@@ -758,7 +758,8 @@ static inline void assign_svalue(struct svalue *to, const struct svalue *from)
 
 #define INIT_PIKE_MEMOBJ(X) do {			\
   struct ref_dummy *v_=(struct ref_dummy *)(X);		\
-  v_->refs=1;						\
+  v_->refs=0;						\
+  add_ref(v_); /* For DMALLOC... */			\
   DO_IF_SECURITY( INITIALIZE_PROT(v_) );		\
   IF_LOCAL_MUTEX(mt_init_recursive(&(v_->mutex)));	\
 }while(0)