On Wed 09 Sep 2020 08:59:25 PM CEST, Vladimir Sementsov-Ogievskiy
<[email protected]> wrote:
> + * On success return true with bm_list set (probably to NULL, if no bitmaps),
" probably " ? :-)
> + * on failure return false with errp set.
> */
> -Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
> - Error **errp)
> +bool qcow2_get_bitmap_info_list(BlockDriverState *bs,
> + Qcow2BitmapInfoList **info_list, Error
> **errp)
> {
> BDRVQcow2State *s = bs->opaque;
> Qcow2BitmapList *bm_list;
> Qcow2Bitmap *bm;
> - Qcow2BitmapInfoList *list = NULL;
> - Qcow2BitmapInfoList **plist = &list;
So here 'list' points at NULL and 'plist' at &list.
> - *plist = obj;
> - plist = &obj->next;
In the original code 'plist' is updated when you add a new element, so
it always points at the end of the list. But 'list' is unchanged and it
still points at the first element.
So the caller receives a pointer to the first element.
> + *info_list = obj;
> + info_list = &obj->next;
But in the new code there is only one variable (passed by the caller),
which always points at the end of the list.
Berto