fix last change and use stdbool.h
This commit is contained in:
parent
7f1f0249f3
commit
f3db74395d
1 changed files with 10 additions and 11 deletions
|
@ -11,12 +11,14 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <cc65.h>
|
#include <cc65.h>
|
||||||
|
|
||||||
|
|
||||||
int printdir (char *newdir)
|
/* returns true for error, false for OK */
|
||||||
|
bool printdir (char *newdir)
|
||||||
{
|
{
|
||||||
char *olddir;
|
char *olddir;
|
||||||
char *curdir;
|
char *curdir;
|
||||||
|
@ -27,10 +29,9 @@ int printdir (char *newdir)
|
||||||
unsigned num;
|
unsigned num;
|
||||||
|
|
||||||
olddir = malloc (FILENAME_MAX);
|
olddir = malloc (FILENAME_MAX);
|
||||||
if (olddir != NULL) {
|
if (olddir == NULL) {
|
||||||
|
|
||||||
perror ("cannot allocate memory");
|
perror ("cannot allocate memory");
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getcwd (olddir, FILENAME_MAX);
|
getcwd (olddir, FILENAME_MAX);
|
||||||
|
@ -41,14 +42,13 @@ int printdir (char *newdir)
|
||||||
*/
|
*/
|
||||||
printf (" Dir %s\n", newdir);
|
printf (" Dir %s\n", newdir);
|
||||||
free (olddir);
|
free (olddir);
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
curdir = malloc (FILENAME_MAX);
|
curdir = malloc (FILENAME_MAX);
|
||||||
if (curdir != NULL) {
|
if (curdir == NULL) {
|
||||||
|
|
||||||
perror ("cannot allocate memory");
|
perror ("cannot allocate memory");
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We call getcwd() in order to print the
|
/* We call getcwd() in order to print the
|
||||||
|
@ -88,7 +88,7 @@ int printdir (char *newdir)
|
||||||
|
|
||||||
chdir (olddir);
|
chdir (olddir);
|
||||||
free (olddir);
|
free (olddir);
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,8 +98,7 @@ void main (void)
|
||||||
char *devicedir;
|
char *devicedir;
|
||||||
|
|
||||||
devicedir = malloc (FILENAME_MAX);
|
devicedir = malloc (FILENAME_MAX);
|
||||||
if (devicedir != NULL) {
|
if (devicedir == NULL) {
|
||||||
|
|
||||||
perror ("cannot allocate memory");
|
perror ("cannot allocate memory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue