Free some allocations

This commit is contained in:
Sanel Zukan 2009-10-03 12:28:41 +00:00
parent 82b85f20be
commit ddb8ae12b0

View File

@ -167,13 +167,18 @@ static int start_child_process(const char* cmd) {
close(err[1]);
break;
default:
/* perent */
/* parent */
close(in[0]);
close(out[1]);
close(err[1]);
break;
}
/* cleanup when returns from the child */
for(int i = 0; params[i]; i++)
free(params[i]);
free(params);
int status, ret;
errno = 0;
if(waitpid(pid, &status, 0) < 0) {
@ -326,12 +331,9 @@ static int start_dialog(int argc, char** argv) {
}
int main(int argc, char** argv) {
if(argc == 1)
if(argc <= 1)
return start_dialog(argc, argv);
if(argc > 1) {
/* do not see possible flags as commands */
if(argv[1][0] == '-') {
help();
@ -340,6 +342,7 @@ int main(int argc, char** argv) {
String args;
unsigned int alen;
for(int i = 1; i < argc; i++) {
args += argv[i];
args += ' ';
@ -368,7 +371,6 @@ int main(int argc, char** argv) {
} else {
start_child(args.c_str());
}
}
return 0;
}