This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Newxz() can use calloc() rather than malloc(), as the implementation
authorNicholas Clark <nick@ccl4.org>
Wed, 12 Apr 2006 12:31:29 +0000 (12:31 +0000)
committerNicholas Clark <nick@ccl4.org>
Wed, 12 Apr 2006 12:31:29 +0000 (12:31 +0000)
of calloc() may know that it has fresh pages from the OS, and so
doesn't need to zero them itself. Plus our object code should be
slightly smaller.

p4raw-id: //depot/perl@27774

handy.h

diff --git a/handy.h b/handy.h
index 010cd9a..db9e006 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -717,8 +717,7 @@ Malloc_t Perl_mem_log_free(Malloc_t oldalloc, const char *filename, const int li
 
 #define Newx(v,n,t)    (v = (MEM_WRAP_CHECK_(n,t) MEM_LOG_ALLOC(n,t,(t*)safemalloc((MEM_SIZE)((n)*sizeof(t))))))
 #define Newxc(v,n,t,c) (v = (MEM_WRAP_CHECK_(n,t) MEM_LOG_ALLOC(n,t,(c*)safemalloc((MEM_SIZE)((n)*sizeof(t))))))
-#define Newxz(v,n,t)   (v = (MEM_WRAP_CHECK_(n,t) MEM_LOG_ALLOC(n,t,(t*)safemalloc((MEM_SIZE)((n)*sizeof(t)))))), \
-                       memzero((char*)(v), (n)*sizeof(t))
+#define Newxz(v,n,t)   (v = (MEM_WRAP_CHECK_(n,t) MEM_LOG_ALLOC(n,t,(t*)safecalloc((n),sizeof(t)))))
 
 #ifndef PERL_CORE
 /* pre 5.9.x compatibility */