On Mon, Mar 27, 2023 at 4:13 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote: > > On Mon, 2023-03-27 at 15:50 -0700, Andrii Nakryiko wrote: > [...] > > > > > > I finally got back to this and have a question which I should have > > > asked on Thursday, sorry. Why do you want to preserve a call to > > > realloc() when dst_final_sz is 0? > > > > Because it's supposed to work correctly. Why is it weird? realloc API > > is supposed to work with zeros, so I'd rather have one code path that > > handles all the cases instead of avoiding calling realloc(). > > Having two ways to encode effectively identical state feels weird. It's weird on the realloc() side. But from libbpf's side, we always call realloc(), always use its results, always pass it into free(). It's one way: consistently use realloc()+free() API. > Ok, thank you, I'll send the patch the way you suggest shortly. > > [...]