$NetBSD: patch-aa,v 1.4 2005/07/12 20:16:00 hubertf Exp $

--- xdu.c.orig	2005-07-11 23:15:31.000000000 +0200
+++ xdu.c	2005-07-11 23:19:59.000000000 +0200
@@ -19,13 +19,15 @@
  * limitation a license to do the foregoing actions under any patents of
  * the party supplying this software to the X Consortium.
  */
+#include <assert.h>
 #include <stdio.h>
+#include <string.h>
 #include "version.h"
 
 extern char *malloc(), *calloc();
 
-#define	MAXDEPTH	80	/* max elements in a path */
-#define	MAXNAME		1024	/* max pathname element length */
+#define	MAXDEPTH	1024	/* max elements in a path */
+#define	MAXNAME		4096	/* max pathname element length */
 #define	MAXPATH		4096	/* max total pathname length */
 #define	NCOLS		5	/* default number of columns in display */
 
@@ -96,6 +98,10 @@
 	struct	node	*np;
 
 	np = (struct node *)calloc(1,sizeof(struct node));
+	if (np == NULL) {
+		fprintf(stderr, "Out of memory! (#1)\n");
+		exit(1);
+	}
 	np->name = strdup(name);
 	np->size = size;
 	np->num = nnodes;
@@ -610,6 +616,7 @@
 		100.0*topp->size/rootp->size);
 }
 
+#if !defined(__NetBSD__) && !defined(SVR4) /* == Solaris etc. */
 char *
 strdup(s)
 char *s;
@@ -619,10 +626,15 @@
 
 	n = strlen(s);
 	cp = malloc(n+1);
+	if (cp == NULL) {
+		fprintf(stderr, "Out of memory! (#2)\n");
+		exit(1);
+	}
 	strcpy(cp,s);
 
 	return	cp;
 }
+#endif /* __NetBSD__ */
 
 /**************** External Entry Points ****************/
 
