summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2005-07-11 18:29:46 +0300
committerDave Mitchell <davem@fdisolutions.com>2005-07-12 18:46:34 +0000
commite352bcff231c07cf21f07ae801f374a3da3229ed (patch)
tree362ddec7569a75cf6e103cb1babaf1bffa4929b8 /util.c
parent282e17420839364a06808f9f85ab641c510d8296 (diff)
downloadperl-e352bcff231c07cf21f07ae801f374a3da3229ed.tar.gz
Make PERL_MEM_LOG more portable.
Message-Id: <42D2663A.4050204@gmail.com> p4raw-id: //depot/perl@25128
Diffstat (limited to 'util.c')
-rw-r--r--util.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/util.c b/util.c
index 6caedaafc5..74f5944269 100644
--- a/util.c
+++ b/util.c
@@ -4960,17 +4960,19 @@ Perl_free_global_struct(pTHX_ struct perl_vars *plvarsp)
#ifdef PERL_MEM_LOG
+#define PERL_MEM_LOG_SPRINTF_BUF_SIZE 128
+
Malloc_t
Perl_mem_log_alloc(const UV n, const UV typesize, const char *typename, Malloc_t newalloc, const char *filename, const int linenumber, const char *funcname)
{
#ifdef PERL_MEM_LOG_STDERR
- /* We can't use PerlIO_printf() for obvious reasons. */
- char buf[1024];
+ /* We can't use PerlIO for obvious reasons. */
+ char buf[PERL_MEM_LOG_SPRINTF_BUF_SIZE];
sprintf(buf,
"alloc: %s:%d:%s: %"IVdf" %"UVuf" %s = %"IVdf": %"UVxf"\n",
filename, linenumber, funcname,
n, typesize, typename, n * typesize, PTR2UV(newalloc));
- write(2, buf, strlen(buf));
+ PerlLIO_write(2, buf, strlen(buf));
#endif
return newalloc;
}
@@ -4979,13 +4981,13 @@ Malloc_t
Perl_mem_log_realloc(const UV n, const UV typesize, const char *typename, Malloc_t oldalloc, Malloc_t newalloc, const char *filename, const int linenumber, const char *funcname)
{
#ifdef PERL_MEM_LOG_STDERR
- /* We can't use PerlIO_printf() for obvious reasons. */
- char buf[1024];
+ /* We can't use PerlIO for obvious reasons. */
+ char buf[PERL_MEM_LOG_SPRINTF_BUF_SIZE];
sprintf(buf,
"realloc: %s:%d:%s: %"IVdf" %"UVuf" %s = %"IVdf": %"UVxf" -> %"UVxf"\n",
filename, linenumber, funcname,
n, typesize, typename, n * typesize, PTR2UV(oldalloc), PTR2UV(newalloc));
- write(2, buf, strlen(buf));
+ PerlLIO_write(2, buf, strlen(buf));
#endif
return newalloc;
}
@@ -4994,11 +4996,11 @@ Malloc_t
Perl_mem_log_free(Malloc_t oldalloc, const char *filename, const int linenumber, const char *funcname)
{
#ifdef PERL_MEM_LOG_STDERR
- /* We can't use PerlIO_printf() for obvious reasons. */
- char buf[1024];
+ /* We can't use PerlIO for obvious reasons. */
+ char buf[PERL_MEM_LOG_SPRINTF_BUF_SIZE];
sprintf(buf, "free: %s:%d:%s: %"UVxf"\n",
filename, linenumber, funcname, PTR2UV(oldalloc));
- write(2, buf, strlen(buf));
+ PerlLIO_write(2, buf, strlen(buf));
#endif
return oldalloc;
}