On Wed, Nov 02, 2011 at 04:28:54PM -0600, Eric Blake wrote: > On 11/02/2011 04:00 PM, Guido Günther wrote: > >>>+ template = strdup("/tmp/libvirt_XXXXXX"); > >> > >>No need to malloc() the template. Just do: > >> > >>char template[] = "/tmp/libvirt_XXXXXX"; > > > >This was actually the first version I had but it didn't seem to match > >libvirt's style (in the non-const form and I didn't find it in HACKING) > > For something short-lived and cleanly scoped, stack allocation of > less than 4k bytes is fine; in fact it is even preferable (more > efficient, fewer failure points). Perhaps most existing uses of > mk[ds]temp in libvirt.git happened to malloc, but that's probably > because they are in situations where the final name must survive the > scope of the function creating the file. I don't know that HACKING > has to specifically speak to this, but I'll review any patch if you > want to tweak it to make that clear. I think it's fine as is, I was just wondering about only finding a single other usage. > > >so I went for the explicit strdup. New version attached. > > ACK to this version. Pushed now. Thanks, -- Guido -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list