On Thu, Mar 28, 2019 at 09:39:23PM -0500, Eric Blake wrote:
On 3/28/19 11:18 AM, Richard W.M. Jones wrote:
--- filters/truncate/truncate.c | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
+ extents2 = nbdkit_extents_new (0, real_size_copy); + if (offset + count <= real_size_copy) + n = count; + else + n = real_size_copy - offset; + if (next_ops->extents (nxdata, n, offset, flags, extents2, err) == -1) { + nbdkit_extents_free (extents2); + return -1; + } + + for (i = 0; i < nbdkit_extents_count (extents2); ++i) { + struct nbdkit_extent e = nbdkit_get_extent (extents2, i); + + if (nbdkit_add_extent (extents, e.offset, e.length, e.type) == -1) { + nbdkit_extents_free (extents2); + return -1; + } + } + nbdkit_extents_free (extents2); +
Should we be using the CLEANUP_EXTENTS_FREE macro here and in other filters?
At the moment the CLEANUP_* macros are only available to server code, not to plugins or filters. They would certainly make plugins and filters easier to write. I would really like attribute((cleanup)) to turn up in ISO C one day :-) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top