[libvirt] [PATCH] Introduce APIs for splitting/joining strings

Eric Blake eblake at redhat.com
Fri Nov 30 16:09:34 UTC 2012


> > This introduces a few new APIs for dealing with strings.
> > One to split a char * into a char **, another to join a
> > char ** into a char *, and finally one to free a char **
> > 

> 
> Opps, the virstring.c file should have this patch spliced in

Oh, you're copying code.  Which means my suggestion of letting the
user specify a length rather than forcing them to NULL-terminate
their array would mean you are no longer matching the version
that you copied from (not necessarily a bad thing).

> +/**
> + * virStringSplit:
> + * @string: a string to split
> + * @delim: a string which specifies the places at which to split
> + *     the string. The delimiter is not included in any of the
> resulting
> + *     strings, unless @max_tokens is reached.
> + * @max_tokens: the maximum number of pieces to split @string into.
> + *     If this is less than 1, the string is split completely.

"less than 1" means "exactly 0", since it is an unsigned param.




More information about the libvir-list mailing list