On Thu, 22 Oct 2009 10:05:02 +0100 Alan Maguire <Alan.Maguire at Sun.COM> wrote:
> Michael Hunter wrote: > > On Wed, 21 Oct 2009 21:32:49 +0100 > > Alan Maguire <Alan.Maguire at Sun.COM> wrote: > > > > > >> sorry I missed this earlier. Comments inline below... > >> > >> Michael Hunter wrote: > >> > >>> On Fri, 16 Oct 2009 13:37:28 +0100 > >>> Alan Maguire <Alan.Maguire at Sun.COM> wrote: > >>> > >>> > >>> > >>>> ...at: > >>>> > >>>> http://zhadum.east.sun.com/export/ws/amaguire/nwam1-cr/webrev/ > >>>> > >>>> > >>> comments on the current implementation in case you don't like my other > >>> idea |: > >>> > >>> strsep() might be easier then strtok_r(). > >>> > >>> Run over the string once counting spaces so you can allocate the right > >>> length of argv and you can't ditch the realloc() logic. > >>> > >>> > >> What about using the strategy we use in a few places > >> in libnwam - we calloc as much memory as we'd conceivably need > >> (in this case NWAM_MAX_VALUE_LEN/2 char * pointers > >> is the maximum number of arguments we can cram into > >> a string property), then we realloc to shrink down the block > >> of char * pointers when we've parsed the string and > >> determined the number of arguments? > >> > > > > The realloc to shrink is fine also. You could use strlen() as the max > > although > > > > for (count = 0; *cp != 0; cp++) if (isspace(*cp)) count++; > > > > seems reasonable to me. > > > > > webrev > > http://zhadum.east.sun.com/export/ws/amaguire/nwam1-cr/webrev/ > > > ...has been respun to include enm.c fixes. Thanks! Looks good. Michael > > Alan
