changeset 429:1185c50d4b08

fix dstress.c's memory handling Anders F Bj?rklund <afb@algonet.se> 2005-04-12 mail:e14e64af760e8d69035a1d3d7dd9ee78@algonet.se
author thomask
date Tue, 12 Apr 2005 16:40:27 +0000
parents 115678dd30b7
children 6a663dfca2a5
files dstress.c
diffstat 1 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dstress.c	Tue Apr 12 16:16:17 2005 +0000
+++ b/dstress.c	Tue Apr 12 16:40:27 2005 +0000
@@ -85,10 +85,28 @@
 		}
 		close(file);
 	}
-	errno = 0;
 	return back;
 }
 
+void *xmalloc(size_t size)
+{
+	void *p;
+	if (p < 0)
+	{
+		fprintf(stderr,"Failed to allocate %ld bytes!\n", size);
+		exit(1);			
+	}
+	p = malloc(size);
+	if (p == NULL)
+	{
+		fprintf(stderr,"Failed to allocate %ld bytes!\n", size);
+		exit(1);			
+	}
+	return p;
+}
+
+#define malloc xmalloc
+
 #else
 
 #ifdef WIN32
@@ -180,7 +198,7 @@
 		}
 	}
 
-	return "";
+	return calloc(1,1);
 }