]> git.ipfire.org Git - thirdparty/libvirt.git/commit
buf: support peeking at string contents
authorEric Blake <eblake@redhat.com>
Fri, 8 Jun 2012 19:50:23 +0000 (13:50 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 11 Jun 2012 15:21:27 +0000 (09:21 -0600)
commit9202f2c2204cd66b75ac0f8be15577697f56c0e2
treec32baa079fa9a80fcb26ebcd3f2258b505309015
parent539e9b34b90e4d63d07e471d6e24eeba7f1bb1db
buf: support peeking at string contents

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.
src/libvirt_private.syms
src/util/buf.c
src/util/buf.h
tests/virbuftest.c