On Tue, Jun 27, 2017 at 1:34 PM, Fam Zheng <f...@redhat.com> wrote: > On Mon, 06/05 13:22, Ashijeet Acharya wrote: >> @@ -1876,6 +1942,13 @@ static int vmdk_pwritev(BlockDriverState *bs, >> uint64_t offset, >> offset += n_bytes; >> bytes_done += n_bytes; >> >> + while (m_data->next != NULL) { > > If you do > > while (m_data) { > >> + VmdkMetaData *next; >> + next = m_data->next; >> + g_free(m_data); >> + m_data = next; >> + } >> + >> /* update CID on the first write every time the virtual disk is >> * opened */ >> if (!s->cid_updated) { >> @@ -1886,6 +1959,7 @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_t >> offset, >> s->cid_updated = true; >> } >> } >> + g_free(m_data); > > then you can remove this line.
As I explained last time, I can't do this because I am reusing the first allocated m_data. If I am to do it the way you suggest, I will have to move the allocation of first m_data (m_data = g_new0(VmdkMetaData, 1)) inside the outer while loop, otherwise things will segfault. Ashijeet