about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-05-17 17:55:37 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-05-17 17:55:37 +0000
commit8ab895baf00686a3d766154d0a07aae92e4475f9 (patch)
treeddbc5e4f265645b1e849560e33ec933c357cc319
parent63b0ca8f378f0c1aa2f3e8858e4e2ea91d645218 (diff)
downloadzsh-8ab895baf00686a3d766154d0a07aae92e4475f9.tar.gz
zsh-8ab895baf00686a3d766154d0a07aae92e4475f9.tar.xz
zsh-8ab895baf00686a3d766154d0a07aae92e4475f9.zip
25057: better debug error on memory failure
-rw-r--r--ChangeLog3
-rw-r--r--Src/mem.c2
-rw-r--r--Src/utils.c7
3 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c58c0d672..7518c0ace 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-05-17  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* 25057: Src/mem.c, Src/utils.c: better debug info for memory
+	errors.
+
 	* 25055: Src/pattern.c: remove unnecessary debug test.
 
 2008-05-16  Peter Stephenson  <pws@csr.com>
diff --git a/Src/mem.c b/Src/mem.c
index 448c4aad9..88cd6247a 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -958,7 +958,7 @@ malloc(MALLOC_ARG_T size)
 	n = (size + M_HSIZE + M_ALLOC + m_pgsz - 1) & ~(m_pgsz - 1);
 
 	if (((char *)(m = (struct m_hdr *)sbrk(n))) == ((char *)-1)) {
-	    DPUTS(1, "MEM: allocation error at sbrk.");
+	    DPUTS1(1, "MEM: allocation error at sbrk, size %L.", n);
 	    unqueue_signals();
 	    return NULL;
 	}
diff --git a/Src/utils.c b/Src/utils.c
index a1a97d182..2873e63dc 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -255,6 +255,7 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
 {
     const char *str;
     int num;
+    long lnum;
 #ifdef HAVE_STRERROR_R
 #define ERRBUFSIZE (80)
     int olderrno;
@@ -286,6 +287,12 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
 		nicezputs(s, file);
 		break;
 	    }
+#ifdef DEBUG
+	    case 'L':
+		lnum = va_arg(ap, long);
+		fprintf(file, "%ld", lnum);
+		break;
+#endif
 	    case 'd':
 		num = va_arg(ap, int);
 		fprintf(file, "%d", num);