On 4/27/07, Noah Heusser <[EMAIL PROTECTED]> wrote:
+ char *file = "nohup.out";
[...]
+ case 'f': + file = strdup(optarg); + break;
Handling memory allocation in this way is a bit awkward. What is one supposed to do with "file" once one is finished with it? If the -f option was never given, file points at a fixed buffer which needs no tidying up. If the -f option was not given, file points at a buffer which had been allocated via malloc(). So the cleanup code would have to look like this: if (f_option_had_been_given) free(file); Instead of doing this and introducing the extra variable, it is simpler to just do this:- case 'f': file = optarg; break; Here, the string is not duplicated, file just points to the relevant command-line argument. Therefore it won't need to be free()d. This approach works as long as nohup doesn't modify its own command-line arguments. A second option of course is not to worry about the memory leak, which after all does not occur within a loop. That's the approach you are taking. There's nothing wrong with that approach; nohup only allocates the memory once so the impact of the leak is minimal. James. _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils