mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
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.
This commit is contained in:
parent
73690f8f83
commit
a61c784b8c
5 changed files with 5 additions and 5 deletions
|
|
@ -80,7 +80,7 @@ struct dir_output {
|
||||||
/* The output code is responsible for updating these stats. Can be 0 when not
|
/* The output code is responsible for updating these stats. Can be 0 when not
|
||||||
* available. */
|
* available. */
|
||||||
int64_t size;
|
int64_t size;
|
||||||
long items;
|
int items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ void dir_draw() {
|
||||||
if(dir_fatalerr)
|
if(dir_fatalerr)
|
||||||
fprintf(stderr, "\r%s.\n", dir_fatalerr);
|
fprintf(stderr, "\r%s.\n", dir_fatalerr);
|
||||||
else
|
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));
|
cropstr(dir_curpath, 55), dir_output.items, formatsize(dir_output.size));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ struct dir {
|
||||||
struct dir *parent, *next, *prev, *sub, *hlnk;
|
struct dir *parent, *next, *prev, *sub, *hlnk;
|
||||||
int64_t size, asize;
|
int64_t size, asize;
|
||||||
ino_t ino;
|
ino_t ino;
|
||||||
long items;
|
int items;
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
unsigned char flags;
|
unsigned char flags;
|
||||||
char name[3]; /* must be large enough to hold ".." */
|
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) {
|
while(d) {
|
||||||
d->size += size;
|
d->size += size;
|
||||||
d->asize += asize;
|
d->asize += asize;
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ char *getpath(struct dir *);
|
||||||
struct dir *getroot(struct dir *);
|
struct dir *getroot(struct dir *);
|
||||||
|
|
||||||
/* Adds a value to the size, asize and items fields of *d and its parents */
|
/* 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
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue