Skip to content
Snippets Groups Projects
Commit a61c784b authored by Yorhel's avatar Yorhel
Browse files

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.
parent 73690f8f
No related branches found
No related tags found
No related merge requests found
......@@ -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;
};
......
......@@ -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:
......
......@@ -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 ".." */
......
......@@ -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;
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment