Hi Joel,

attached there are two git formated patches which make ccache also work on
Tru64 and AIX.

As both of the machines where I hit that problems are in the build farm,
I'd suggest you also add some real life test in the build farm. For example:
build ccache, move the ccache binary away, make clean and redo the build using
the fresh compiled ccache again. That test would have uncovered this bugs with
malloc/calloc, too. What do you think about that?

Cheers
Björn
From 07d4cbbd5692eab01f3f2051c82b8693f0eb78da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= <b...@sernet.de>
Date: Tue, 9 Nov 2010 21:30:16 +0100
Subject: [PATCH 1/2] fix malloc success check

On AIX and Tru64 I had issues with this: If you allocate 0 byte then you may
get e NULL pointer back which is not a sign of an error.
---
 util.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/util.c b/util.c
index 27452a2..a1dec72 100644
--- a/util.c
+++ b/util.c
@@ -597,7 +597,7 @@ x_malloc(size_t size)
 {
 	void *ret;
 	ret = malloc(size);
-	if (!ret) {
+	if (!ret && size) {
 		fatal("x_malloc: Could not allocate %lu bytes", (unsigned long)size);
 	}
 	return ret;
-- 
1.7.3.1

From 56a0fb5a3514e6283277a4dde8e21db6f8819e99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= <b...@sernet.de>
Date: Tue, 9 Nov 2010 21:33:46 +0100
Subject: [PATCH 2/2] fix calloc success check

On Tru64 I had issues with this: If the number of elements or the size is 0
then you may get a NULL pointer back. which is not a sign of an error.
---
 util.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/util.c b/util.c
index a1dec72..2c899c7 100644
--- a/util.c
+++ b/util.c
@@ -609,7 +609,7 @@ x_calloc(size_t nmemb, size_t size)
 {
 	void *ret;
 	ret = calloc(nmemb, size);
-	if (!ret) {
+	if (!ret && nmemb && size) {
 		fatal("x_calloc: Could not allocate %lu bytes", (unsigned long)size);
 	}
 	return ret;
-- 
1.7.3.1

Attachment: pgpyrjpXHLcax.pgp
Description: PGP signature

_______________________________________________
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache

Reply via email to