From a61c784b8c0d5595a85fb3b0233b2cc75e14716c Mon Sep 17 00:00:00 2001 From: Yorhel <git@yorhel.nl> Date: Mon, 27 Aug 2012 18:32:29 +0200 Subject: [PATCH] Use int instead of long for struct dir->items 2 billion files should be enough for everyone. You probably won't have enough memory to scan such a filesystem. int is a better choice than long, as sizeof(int) is 4 on pretty much any system where ncdu runs. --- src/dir.h | 2 +- src/dir_common.c | 2 +- src/global.h | 2 +- src/util.c | 2 +- src/util.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dir.h b/src/dir.h index 94899ab..e9d42f9 100644 --- a/src/dir.h +++ b/src/dir.h @@ -80,7 +80,7 @@ struct dir_output { /* The output code is responsible for updating these stats. Can be 0 when not * available. */ int64_t size; - long items; + int items; }; diff --git a/src/dir_common.c b/src/dir_common.c index b0080cd..f13e667 100644 --- a/src/dir_common.c +++ b/src/dir_common.c @@ -182,7 +182,7 @@ void dir_draw() { if(dir_fatalerr) fprintf(stderr, "\r%s.\n", dir_fatalerr); else - fprintf(stderr, "\r%-55s %8ld files /%s", + fprintf(stderr, "\r%-55s %8d files /%s", cropstr(dir_curpath, 55), dir_output.items, formatsize(dir_output.size)); break; case 2: diff --git a/src/global.h b/src/global.h index e244d27..e1f273e 100644 --- a/src/global.h +++ b/src/global.h @@ -62,7 +62,7 @@ struct dir { struct dir *parent, *next, *prev, *sub, *hlnk; int64_t size, asize; ino_t ino; - long items; + int items; dev_t dev; unsigned char flags; char name[3]; /* must be large enough to hold ".." */ diff --git a/src/util.c b/src/util.c index f78bddd..0cd7fb1 100644 --- a/src/util.c +++ b/src/util.c @@ -283,7 +283,7 @@ struct dir *getroot(struct dir *d) { } -void addparentstats(struct dir *d, int64_t size, int64_t asize, long items) { +void addparentstats(struct dir *d, int64_t size, int64_t asize, int items) { while(d) { d->size += size; d->asize += asize; diff --git a/src/util.h b/src/util.h index a8dd116..ac6b467 100644 --- a/src/util.h +++ b/src/util.h @@ -82,7 +82,7 @@ char *getpath(struct dir *); struct dir *getroot(struct dir *); /* Adds a value to the size, asize and items fields of *d and its parents */ -void addparentstats(struct dir *, int64_t, int64_t, long); +void addparentstats(struct dir *, int64_t, int64_t, int); #endif -- GitLab