Pádraig Brady wrote: > Jim Meyering wrote: >> Pádraig Brady wrote: >> ... >>> copy_file_preserving (const char *src_filename, const char *dest_filename) >>> @@ -58,8 +60,7 @@ copy_file_preserving (const char *src_filename, const >>> char *dest_filename) >>> struct stat statbuf; >>> int mode; >>> int dest_fd; >>> - char buf[4096]; >>> - const size_t buf_size = sizeof (buf); >>> + char *buf = xmalloc (IO_SIZE); >> >> Hi Pádraig, >> >> We must not use functions like xmalloc (that can exit) >> from within library code. >> >> Instead, you might want to use malloc, and if that fails, >> revert to using the buffer on the stack. > > copy_file_preserving() already exits on error > (and is documented to do so), which is why > I used xmalloc there?
<blush!> You're right. Don't mind me ;-)