optimizing for dev/null

This commit is contained in:
elvis
2022-05-03 23:30:47 +02:00
parent 4b7f15c555
commit f64dd54b84

View File

@ -1165,6 +1165,10 @@ int setDirectory(char* Dir, int rw) {
if(openedFiles->validwDir) {
free(openedFiles->wDir);
openedFiles->wDir = NULL;
openedFiles->validwDir = 0;
}
if(strncmp(Dir, "/dev/null", strlen("/dev/null")+1) == 0) {
return 0;
}
openedFiles->validwDir = 1;
openedFiles->wDir = malloc(strlen(Dir)+1);
@ -1173,6 +1177,10 @@ int setDirectory(char* Dir, int rw) {
if(openedFiles->validrDir) {
free(openedFiles->rDir);
openedFiles->rDir = NULL;
openedFiles->validrDir = 0;
}
if(strncmp(Dir, "/dev/null", strlen("/dev/null")+1) == 0) {
return 0;
}
openedFiles->validrDir = 1;
openedFiles->rDir = malloc(strlen(Dir)+1);