[libvirt] [PATCH] tests: dynamically replace dnsmasq path
Philipp Hahn
hahn at univention.de
Tue Jan 31 14:58:06 UTC 2012
Hello Eric,
Am Montag 30 Januar 2012 20:18:15 schrieb Eric Blake:
> > + if (diff > 0) {
> > + tmp = realloc((void *)*buf, new_len);
>
> We should not be using realloc in this file, but should be using
> VIR_RESIZE_N or similar.
Okay, makes the code even more readable.
> > + memmove(token_start, replacement, replacement_len);
>
> But this would be more efficient as memcpy, since replacement (better
> not) overlap with token_start.
I know of some projects which forbid memcpy() because of the missing overlap
handling. But if this is okay with libvirt, I'll use it.
I hope performance will never be a problem with this simple test scenario,
because then doing one realloc() instead of one for each found would be
better.
> > + if (diff < 0) {
> > + tmp = realloc((void *)*buf, new_len);
>
> No need to downsize the allocation - it's okay to leave junk in the tail
> end of the buffer, as long as we have a trailing NUL to stop us in time.
Fine with me for this simple test case, but if that would be generalized and
be used in other places, this might become a problem. I'll add a comment.
Sincerely
Philipp
--
Philipp Hahn Open Source Software Engineer hahn at univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99
http://www.univention.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120131/607775f6/attachment-0001.sig>
More information about the libvir-list
mailing list