Index: trunk/src/bignum.c
===================================================================
--- trunk/src/bignum.c	(revision 453)
+++ trunk/src/bignum.c	(revision 454)
@@ -64,9 +64,4 @@
 #define ulong unsigned long
 
-/*
-extern void *malloc(size_t size);
-extern void free();
-*/
-
 char *last_string    = NULL;
 char *big_end_string = NULL;
@@ -232,5 +227,5 @@
     dgs_alloc += alloclen;
 #endif
-    digit_ptr = (DIGIT *) malloc(alloclen * sizeof(DIGIT));
+    digit_ptr = calloc(alloclen, sizeof(DIGIT));
     if (digit_ptr == NULL)
     {
@@ -625,5 +620,5 @@
     big_set_long((long)1, &big_one);
     length_last_string = 10;
-    if ((last_string = malloc(length_last_string)) == NULL)
+    if ((last_string = calloc(1,length_last_string)) == NULL)
     {
 	big_errno = BIG_MEMERR;
@@ -955,5 +950,5 @@
 	if (last_string != NULL)
 	  free(last_string);
-	if ((last_string = malloc(str_length)) == NULL)
+	if ((last_string = calloc(1,str_length)) == NULL)
 	{
 	    big_errno = BIG_MEMERR;
Index: trunk/src/samhain.c
===================================================================
--- trunk/src/samhain.c	(revision 453)
+++ trunk/src/samhain.c	(revision 454)
@@ -150,5 +150,5 @@
 int sh_g_thread()
 {
-  struct gt * ptr = malloc(sizeof(struct gt));
+  struct gt * ptr = calloc(1,sizeof(struct gt));
   if (!ptr)
     return -1;
@@ -640,5 +640,5 @@
   /* The struct to hold privileged information.
    */
-  skey = (sh_key_t *) malloc (sizeof(sh_key_t));
+  skey = calloc(1,sizeof(sh_key_t));
   if (skey != NULL)
     {
@@ -862,5 +862,5 @@
   SH_MUTEX_LOCK(mutex_readdir);
 
-  pidlist =  malloc(sizeof(pid_t) * 65535);
+  pidlist =  calloc(1, sizeof(pid_t) * 65535);
   if (!pidlist)
     goto unlock_and_out;
@@ -1376,5 +1376,5 @@
       if (tzlen < 1024)
 	{
-	  sh.timezone = malloc (tzlen + 1);
+	  sh.timezone = calloc(1, tzlen + 1);
 	  if (sh.timezone != NULL)
 	    (void) sl_strlcpy (sh.timezone, tzptr, tzlen + 1);
Index: trunk/src/sh_database.c
===================================================================
--- trunk/src/sh_database.c	(revision 453)
+++ trunk/src/sh_database.c	(revision 454)
@@ -1484,5 +1484,5 @@
     {
       j = strlen(attr_tab[i].attr_o);
-      attr_tab[i].attr = malloc (j+1); /* only once */
+      attr_tab[i].attr = calloc(1, j+1); /* only once */
       if (NULL == attr_tab[i].attr)
 	return;
Index: trunk/src/sh_entropy.c
===================================================================
--- trunk/src/sh_entropy.c	(revision 453)
+++ trunk/src/sh_entropy.c	(revision 454)
@@ -548,5 +548,5 @@
     {
       len = sl_strlen(sh.timezone) + 4;
-      envp[0] = malloc (len);     /* free() ok     */
+      envp[0] = calloc(1, len);     /* free() ok     */
       if (envp[0] != NULL)
 	sl_snprintf (envp[0], len, "TZ=%s", sh.timezone);
Index: trunk/src/sh_filetype.c
===================================================================
--- trunk/src/sh_filetype.c	(revision 453)
+++ trunk/src/sh_filetype.c	(revision 454)
@@ -472,5 +472,5 @@
 
 #ifdef  SH_FILE_MAIN
-  sh_ftype_arr = malloc((nn+1) * sizeof(struct sh_ftype_rec *));
+  sh_ftype_arr = calloc((nn+1), sizeof(struct sh_ftype_rec *));
 #else
   sh_ftype_arr = SH_ALLOC((nn+1) * sizeof(struct sh_ftype_rec *));
@@ -480,5 +480,5 @@
     {
 #ifdef  SH_FILE_MAIN
-      sh_ftype_arr[i] = malloc(sizeof(struct sh_ftype_rec));
+      sh_ftype_arr[i] = calloc(1, sizeof(struct sh_ftype_rec));
 #else
       sh_ftype_arr[i] = SH_ALLOC(sizeof(struct sh_ftype_rec));
Index: trunk/src/sh_gpg.c
===================================================================
--- trunk/src/sh_gpg.c	(revision 453)
+++ trunk/src/sh_gpg.c	(revision 454)
@@ -422,5 +422,5 @@
     {
       len = sl_strlen(sh.effective.home) + 6;
-      envp[0] = malloc (len); /* free() ok   */
+      envp[0] = calloc(1, len); /* free() ok   */
       if (envp[0] != NULL)
 	sl_snprintf (envp[0], len, _("HOME=%s"), sh.effective.home); 
Index: trunk/src/sh_html.c
===================================================================
--- trunk/src/sh_html.c	(revision 453)
+++ trunk/src/sh_html.c	(revision 454)
@@ -317,5 +317,5 @@
 	  else
 	    {
-	      entry_orig = malloc(line_size + 1);        /* free() ok     */
+	      entry_orig = calloc(1, line_size + 1);        /* free() ok     */
 	      if (entry_orig) { entry_orig[0] = '\0'; add_size = line_size; }
 	    }
Index: trunk/src/sh_inotify.c
===================================================================
--- trunk/src/sh_inotify.c	(revision 453)
+++ trunk/src/sh_inotify.c	(revision 454)
@@ -72,5 +72,5 @@
   if ((ptr = pthread_getspecific(inotify_key)) == NULL) 
     {
-      ptr = malloc(sizeof(int));
+      ptr = calloc(1,sizeof(int));
       if (ptr)
 	{
Index: trunk/src/sh_mem.c
===================================================================
--- trunk/src/sh_mem.c	(revision 453)
+++ trunk/src/sh_mem.c	(revision 454)
@@ -142,5 +142,5 @@
   while (this != NULL) 
     {
-      memlist_t   * merr = (memlist_t *) malloc (sizeof(memlist_t));
+      memlist_t   * merr = calloc(1,sizeof(memlist_t));
 
       memcpy(merr, this, sizeof(memlist_t));
@@ -191,5 +191,5 @@
       if ( this->address == NULL )
 	{
-	  merr = (memlist_t *) malloc (sizeof(memlist_t));
+	  merr = calloc (1,sizeof(memlist_t));
 
 	  memcpy(merr, this, sizeof(memlist_t));
@@ -204,5 +204,5 @@
 	  if ( this->address[this->size]        != CHECKBYTE )
 	    {
-	      merr = (memlist_t *) malloc (sizeof(memlist_t));
+	      merr = calloc(1, sizeof(memlist_t));
 	      
 	      memcpy(merr, this, sizeof(memlist_t));
@@ -215,5 +215,5 @@
 	  if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE )
 	    {
-	      merr = (memlist_t *) malloc (sizeof(memlist_t));
+	      merr = calloc(1, sizeof(memlist_t));
 	      
 	      memcpy(merr, this, sizeof(memlist_t));
@@ -262,5 +262,5 @@
   SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
 
-  the_realAddress = malloc(size + 2 * SH_MEMMULT);
+  the_realAddress = calloc(1,size + 2 * SH_MEMMULT);
   
   if ( the_realAddress  == NULL ) 
@@ -290,5 +290,5 @@
   Mem_Max = ( (Mem_Current > Mem_Max) ? Mem_Current : Mem_Max);
 
-  this = (memlist_t *) malloc (sizeof(memlist_t));
+  this = calloc(1,sizeof(memlist_t));
 
   if ( this == NULL) 
@@ -370,5 +370,5 @@
       if ( this->address[this->size]        != CHECKBYTE )
 	{
-	  merr = (memlist_t *) malloc (sizeof(memlist_t));
+	  merr = calloc(1, sizeof(memlist_t));
 
 	  memcpy(merr, this, sizeof(memlist_t));
@@ -381,5 +381,5 @@
       if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE )
 	{
-	  merr = (memlist_t *) malloc (sizeof(memlist_t));
+	  merr = calloc(1,sizeof(memlist_t));
 
 	  memcpy(merr, this, sizeof(memlist_t));
@@ -454,5 +454,5 @@
   SL_ENTER(_("sh_mem_malloc"));
 
-  theAddress = malloc(size);
+  theAddress = calloc(1,size);
 
   if ( theAddress != NULL ) 
Index: trunk/src/sh_schedule.c
===================================================================
--- trunk/src/sh_schedule.c	(revision 453)
+++ trunk/src/sh_schedule.c	(revision 454)
@@ -335,5 +335,5 @@
   len = strlen(ssched)+1;
 #ifdef TESTONLY
-  copy = malloc(len);                 /* testonly code */
+  copy = calloc(1,len);                 /* testonly code */
 #else
   copy = SH_ALLOC(len);
Index: trunk/src/sh_srp.c
===================================================================
--- trunk/src/sh_srp.c	(revision 453)
+++ trunk/src/sh_srp.c	(revision 454)
@@ -96,5 +96,5 @@
   if (get_str_internal == NULL)
     {
-      get_str_internal = malloc(512);   /* only once */
+      get_str_internal = calloc(1,512);   /* only once */
       if (get_str_internal)
 	{
Index: trunk/src/sh_static.c
===================================================================
--- trunk/src/sh_static.c	(revision 453)
+++ trunk/src/sh_static.c	(revision 454)
@@ -469,10 +469,10 @@
 	struct group group;
 
-	char * buff = malloc(GRP_BUFFER_SIZE_MALLOC);
+	char * buff = calloc(1,GRP_BUFFER_SIZE_MALLOC);
 
 	rv = -1;
 
 	/* We alloc space for 8 gids at a time. */
-	if (((group_list = (gid_t *) malloc(8*sizeof(gid_t *))) != NULL)
+	if (((group_list = calloc(8,sizeof(gid_t *))) != NULL)
 		&& ((grf = fopen(_PATH_GROUP, "r")) != NULL)
 		) {
@@ -1177,6 +1177,6 @@
 	struct resolv_question q;
 	int retries = 0;
-	unsigned char * packet = malloc(PACKETSZ);
-	char *dns, *lookup = malloc(MAXDNAME);
+	unsigned char * packet = calloc(1,PACKETSZ);
+	char *dns, *lookup = calloc(1,MAXDNAME);
 	int variant = 0;
 	struct sockaddr_in sa;
Index: trunk/src/sh_unix.c
===================================================================
--- trunk/src/sh_unix.c	(revision 453)
+++ trunk/src/sh_unix.c	(revision 454)
@@ -1475,5 +1475,5 @@
 
   /* printf("-> %2d: slots allocated\n", envlen); */
-  env1 = malloc (sizeof(char *) * envlen);      /* only once */
+  env1 = calloc(1,sizeof(char *) * envlen);      /* only once */
   if (env1 == NULL)
     {
@@ -1486,5 +1486,5 @@
   while (env0 != NULL && env0[envlen] != NULL) {
     len = strlen(env0[envlen]) + 1;
-    env1[envlen] = malloc (len); /* only once */
+    env1[envlen] = calloc(1,len); /* only once */
     if (env1[envlen] == NULL)
       {
@@ -1910,5 +1910,5 @@
     {
       len = strlen(str) + 1;
-      chroot_dir = malloc(strlen(str) + 1);  /* only once */
+      chroot_dir = calloc(1,strlen(str) + 1);  /* only once */
       if (!chroot_dir)
 	{
@@ -4349,5 +4349,5 @@
 	      sh_error_handle (level, FIL__, __LINE__, stat_return, 
 			       MSG_FI_STAT,
-			       _("lstat"),
+			       _("lstat (link target)"),
 			       sh_error_message (stat_return,errbuf, sizeof(errbuf)), 
 			       (long) euid,
@@ -5568,5 +5568,5 @@
   ptr = pthread_getspecific(gSigtrapVariables_key);
   if (ptr == NULL) {
-    ptr = malloc(sizeof(struct sh_sigtrap_variables));
+    ptr = calloc(1,sizeof(struct sh_sigtrap_variables));
     if (ptr == NULL) {
       return NULL;
Index: trunk/src/sh_utils.c
===================================================================
--- trunk/src/sh_utils.c	(revision 453)
+++ trunk/src/sh_utils.c	(revision 454)
@@ -1255,5 +1255,5 @@
     }
 
-  if (NULL == (new = malloc(strlen(new_in) + 1)))
+  if (NULL == (new = calloc(1,strlen(new_in) + 1)))
     goto bail_mem;
   sl_strncpy(new, new_in, strlen(new_in) + 1);
@@ -1282,5 +1282,5 @@
   len = strlen(path) + 1 + 4;
   /*@-usedef@*/
-  if (NULL == (outpath = malloc(len)))
+  if (NULL == (outpath = calloc(1,len)))
     goto bail_mem;
   /*@-usedef@*/
@@ -1310,5 +1310,5 @@
 
 
-  image = malloc (4096);
+  image = calloc(1,4096);
   if (!image)
     goto bail_mem;
Index: trunk/src/slib.c
===================================================================
--- trunk/src/slib.c	(revision 453)
+++ trunk/src/slib.c	(revision 454)
@@ -1493,5 +1493,5 @@
       char          *  buffer;
       struct passwd *  tempres;
-      buffer = malloc(SH_PWBUF_SIZE);
+      buffer = calloc(1,SH_PWBUF_SIZE);
       SL_REQUIRE (buffer != NULL, _("buffer != NULL"));
       sh_getpwnam_r(user, &pwd, buffer, SH_PWBUF_SIZE, &tempres);
@@ -1542,5 +1542,5 @@
       char          *  buffer;
       struct passwd *  tempres;
-      buffer = malloc(SH_PWBUF_SIZE);
+      buffer = calloc(1,SH_PWBUF_SIZE);
       SL_REQUIRE (buffer != NULL, _("buffer != NULL"));
       sh_getpwnam_r(user, &pwd, buffer, SH_PWBUF_SIZE, &tempres);
@@ -1756,5 +1756,5 @@
     }
 
-  if ( (ofiles[fd] = (SL_OFILE *) malloc(sizeof(SL_OFILE))) == NULL)
+  if ( (ofiles[fd] = calloc(1,sizeof(SL_OFILE))) == NULL)
     {
       SL_IRETURN(SL_EMEM, _("sl_make_ticket"));
@@ -1763,5 +1763,5 @@
   len = sl_strlen(filename)+1;
 
-  if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)
+  if ( (ofiles[fd]->path = calloc(1,len) ) == NULL)
     {
       free (ofiles[fd]);
@@ -2032,5 +2032,5 @@
     }
 
-  if ( (ofiles[fd] = (SL_OFILE *) malloc(sizeof(SL_OFILE))) == NULL)
+  if ( (ofiles[fd] = calloc(1,sizeof(SL_OFILE))) == NULL)
     {
       sl_close_fd(FIL__, __LINE__, fd);
@@ -2040,5 +2040,5 @@
   len = sl_strlen(filename)+1;
 
-  if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)
+  if ( (ofiles[fd]->path = calloc(1,len) ) == NULL)
     {
       free (ofiles[fd]);
Index: trunk/src/sstrip.c
===================================================================
--- trunk/src/sstrip.c	(revision 453)
+++ trunk/src/sstrip.c	(revision 454)
@@ -178,5 +178,5 @@
 
     size = ehdr->e_phnum * sizeof **phdrs;
-    if (!(*phdrs = malloc(size)))
+    if (!(*phdrs = calloc(1,size)))
 	return err("Out of memory!");
 
@@ -196,5 +196,5 @@
 
     size = ehdr->e_phnum * sizeof **phdrs;
-    if (!(*phdrs = malloc(size)))
+    if (!(*phdrs = calloc(1,size)))
 	return err("Out of memory!");
 
Index: trunk/src/t-test1.c
===================================================================
--- trunk/src/t-test1.c	(revision 453)
+++ trunk/src/t-test1.c	(revision 454)
@@ -27,4 +27,14 @@
  * allocated bins per thread.
  */
+/*
+  t-test[12] <n-total> <n-parallel> <n-allocs> <size-max> <bins>
+
+    n-total = total number of threads executed (default 10)
+    n-parallel = number of threads running in parallel (2)
+    n-allocs = number of malloc()'s / free()'s per thread (10000)
+    size-max = max. size requested with malloc() in bytes (10000)
+    bins = number of bins to maintain
+*/
+
 #if defined(HAVE_CONFIG_H)
 #include "config.h"
@@ -52,5 +62,6 @@
 
 #ifdef USE_SYSTEM_MALLOC
-#define memalign(a,b)  malloc(b)
+extern void *memalign(size_t boundary, size_t size);
+/* #define memalign(a,b)  malloc(b) */
 #else
 extern void *memalign(size_t boundary, size_t size);
@@ -203,4 +214,5 @@
 /* Allocate a bin with malloc(), realloc() or memalign().  r must be a
    random number >= 1024. */
+int n_malloc=0, n_memalign=0, n_realloc=0, n_calloc=0;
 
 static void
@@ -219,4 +231,5 @@
 		m->ptr = (unsigned char *)memalign(sizeof(int) << r, size);
 		/* fprintf(stderr, "FIXME memalign %p\n", m->ptr); */
+		++n_memalign;
 	} else if(r < 20) { /* calloc */
 		if(m->size > 0) free(m->ptr);
@@ -232,4 +245,5 @@
 		}
 #endif
+		++n_calloc;
 		/* fprintf(stderr, "FIXME calloc %p\n", m->ptr); */
 	} else if(r < 100 && m->size < REALLOC_MAX) { /* realloc */
@@ -237,8 +251,10 @@
 		m->ptr = realloc(m->ptr, size);
 		/* fprintf(stderr, "FIXME realloc %p\n", m->ptr); */
+		++n_realloc;
 	} else { /* plain malloc */
 		if(m->size > 0) free(m->ptr);
 		m->ptr = (unsigned char *)malloc(size);
 		/* fprintf(stderr, "FIXME malloc %p\n", m->ptr); */
+		++n_malloc;
 	}
 	if(!m->ptr) {
@@ -540,5 +556,7 @@
 		if (verbose)
 		  if(n_total%N_TOTAL_PRINT == 0)
-			printf("n_total = %d\n", n_total);
+			printf("n_total = %8d - malloc %12d / memalign %12d / realloc %12d / calloc %12d\n", 
+				   n_total, 
+				   n_malloc, n_memalign, n_realloc, n_calloc);
 		
 	}
@@ -578,4 +596,15 @@
 	printf("ptmalloc_init\n");
 #endif
+
+	if((argc > 1) && (0 == strcmp(argv[1], "-h") || 0 == strcmp(argv[1], "--help")))
+	  {
+		printf("%s <n-total> <n-parallel> <n-allocs> <size-max> <bins>\n\n", argv[0]);
+		printf(" n-total = total number of threads executed (default 10)\n");
+		printf(" n-parallel = number of threads running in parallel (2)\n");
+		printf(" n-allocs = number of malloc()'s / free()'s per thread (10000)\n");
+		printf(" size-max = max. size requested with malloc() in bytes (10000)\n");
+		printf(" bins = number of bins to maintain\n");
+		return 0;
+	  }
 
 	if(argc > 1) n_total_max = atoi(argv[1]);
Index: trunk/src/trustfile.c
===================================================================
--- trunk/src/trustfile.c	(revision 453)
+++ trunk/src/trustfile.c	(revision 454)
@@ -436,5 +436,5 @@
 
 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  buffer = malloc(SH_GRBUF_SIZE);
+  buffer = calloc(1,SH_GRBUF_SIZE);
   status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g);
 #else
@@ -455,5 +455,5 @@
    */
 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  pbuffer = malloc(SH_PWBUF_SIZE);
+  pbuffer = calloc(1,SH_PWBUF_SIZE);
 #endif
 
@@ -549,5 +549,5 @@
 
 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
-  buffer = malloc(SH_GRBUF_SIZE);
+  buffer = calloc(1,SH_GRBUF_SIZE);
   status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g);
 #else
@@ -580,5 +580,5 @@
    */
 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
-  pbuffer = malloc(SH_PWBUF_SIZE);
+  pbuffer = calloc(1,SH_PWBUF_SIZE);
 #endif
 
@@ -747,5 +747,5 @@
     SL_IRETURN(SL_EBADFILE, _("sl_trustfile"));
 
-  fexp = malloc( MAXFILENAME );
+  fexp = calloc(1, MAXFILENAME );
   if (!fexp)
     SL_IRETURN(SL_EMEM, _("sl_trustfile"));
@@ -863,5 +863,5 @@
 	   * R.W. Tue May 29 22:05:16 CEST 2001
 	   */
-	  csym = malloc( MAXFILENAME );
+	  csym = calloc(1, MAXFILENAME );
 	  if (!csym)
 	    {
@@ -886,5 +886,5 @@
 	    }
 
-	  full = malloc( MAXFILENAME );
+	  full = calloc(1, MAXFILENAME );
 	  if (!full)
 	    {
Index: trunk/src/yulectl.c
===================================================================
--- trunk/src/yulectl.c	(revision 453)
+++ trunk/src/yulectl.c	(revision 454)
@@ -591,5 +591,5 @@
     }
   size = strlen(clientcd) + 1 + strlen(CLIENT) + 6;
-  sockname = malloc (size);
+  sockname = calloc(1,size);
   if (!sockname)
     {
