On Sun, Nov 14, 2010 at 08:52:37PM +0200, Gleb Natapov wrote: > > > + > > > + len = strlen(bootpath); > > > + list = qemu_realloc(list, total + len + 1); > > > + list[total++] = len; > > > + memcpy(&list[total], bootpath, len); > > > + total += len; > > > + c++; > > > + qemu_free(bootpath); > > > > Man, is this tricky. > > > Nah, not at all.
I think it will be easier if we don't try to do this in one pass. 1. pass: calculate total length and # of devices 2. allocate 2. pass fill in > -- > Gleb.