fix last change and use stdbool.h

This commit is contained in:
Christian Groessler 2021-06-10 18:11:45 +02:00 committed by Oliver Schmidt
parent 7f1f0249f3
commit f3db74395d
1 changed files with 10 additions and 11 deletions

View File

@ -11,12 +11,14 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdbool.h>
#include <device.h>
#include <dirent.h>
#include <cc65.h>
int printdir (char *newdir)
/* returns true for error, false for OK */
bool printdir (char *newdir)
{
char *olddir;
char *curdir;
@ -27,10 +29,9 @@ int printdir (char *newdir)
unsigned num;
olddir = malloc (FILENAME_MAX);
if (olddir != NULL) {
if (olddir == NULL) {
perror ("cannot allocate memory");
return 1;
return true;
}
getcwd (olddir, FILENAME_MAX);
@ -41,14 +42,13 @@ int printdir (char *newdir)
*/
printf (" Dir %s\n", newdir);
free (olddir);
return 0;
return false;
}
curdir = malloc (FILENAME_MAX);
if (curdir != NULL) {
if (curdir == NULL) {
perror ("cannot allocate memory");
return 1;
return true;
}
/* We call getcwd() in order to print the
@ -88,7 +88,7 @@ int printdir (char *newdir)
chdir (olddir);
free (olddir);
return 0;
return false;
}
@ -98,8 +98,7 @@ void main (void)
char *devicedir;
devicedir = malloc (FILENAME_MAX);
if (devicedir != NULL) {
if (devicedir == NULL) {
perror ("cannot allocate memory");
return;
}