[libvirt] [PATCH 1/3] virsh: modify vshStringToArray to duplicate the elements too

Peter Krempa pkrempa at redhat.com
Tue Aug 20 09:20:51 UTC 2013


On 08/20/13 11:16, Osier Yang wrote:
> On 20/08/13 17:05, Peter Krempa wrote:
>> At a slightly larger memory expense allow stealing of items from the
>> string array returned from vshStringToArray and turn the result into a
>> string list compatible with virStringSplit. This will allow to use the
>> common dealloc function.
>>
>> This patch also fixes a few forgotten checks of return from
>> vshStringToArray and one memory leak.
>> ---
>>   tools/virsh-nodedev.c  | 18 +++++-------------
>>   tools/virsh-pool.c     | 10 ++++------
>>   tools/virsh-snapshot.c | 10 ++--------
>>   tools/virsh.c          |  8 +++++---
>>   tools/virsh.h          |  1 +
>>   5 files changed, 17 insertions(+), 30 deletions(-)
>>

...

>>
>> diff --git a/tools/virsh.c b/tools/virsh.c
>> index f65dc79..d6e3cb3 100644
>> --- a/tools/virsh.c
>> +++ b/tools/virsh.c
>> @@ -196,7 +196,8 @@ vshStringToArray(const char *str,
> 
> Why not to destroy the use of vshStringToArray, and convert to

vshStringToArray is converting double commas (",,") as escape sequence
for a comma. virStringSplit doesn't do this. We would regress in virsh
option parsing if we'd convert it to virStringSplit.

> virStringSplit? and the comment of vshStringToArray should be updated,
> since the method for free'ing the memory is different now, if we keep
> using it.

Okay, I'll touch up the comment. I didn't notice it contained info how
to free it.

Peter



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130820/55f9060b/attachment-0001.sig>


More information about the libvir-list mailing list