void *safe_malloc(size_t n) {
void *p = malloc(n);
if (!p && n != 0) {
- printf("Can not allocate memory: %s\n", strerror(errno));
+ fprintf(stderr, "Can not allocate memory: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
return p;
result = 0;
if(lstat(name, &dummy) != 0) {
- printf("Can not stat %s: %s\n", name, strerror(errno));
+ fprintf(stderr, "Can not stat %s: %s\n", name, strerror(errno));
exit(EXIT_FAILURE);
}
}
}
closedir(dir);
+ } else {
+ fprintf(stderr, "Can not open ./: %s\n", strerror(errno));
+ exit (EXIT_FAILURE);
}
}
if(isatty(STDOUT_FILENO)) {
struct winsize win;
if(ioctl (STDOUT_FILENO, TIOCGWINSZ, (char *) &win)) {
- printf("Can not get the tty size: %s\n", strerror(errno));
+ fprintf(stderr, "Can not get the tty size: %s\n", strerror(errno));
exit (EXIT_FAILURE);
}
print_sorted(root, win.ws_col, win.ws_row - 2);