[libvirt] [PATCH 1/6] buf: support peeking at string contents

Peter Krempa pkrempa at redhat.com
Mon Jun 11 12:05:30 UTC 2012


On 06/09/12 06:34, Eric Blake wrote:
> Right now, the only way to get at the contents of a virBuffer is
> to destroy it.  But there are cases in my upcoming patches where
> peeking at the contents makes life easier.  I suppose this does
> open up the potential for bad code to dereference a stale pointer,
> by disregarding the docs that the return value is invalid on the
> next virBuf operation, but such is life.
>
> * src/util/buf.h (virBufferCurrentContent): New declaration.
> * src/util/buf.c (virBufferCurrentContent): Implement it.
> * src/libvirt_private.syms (buf.h): Export it.
> * tests/virbuftest.c (testBufAutoIndent): Test it.
> ---

ACK. Might be useful sometimes. I looked for something like this once.

Peter




More information about the libvir-list mailing list