<p dir="ltr"><br>
On Dec 11, 2014 11:07 PM, "Anton Lundin" <<a href="mailto:glance@acc.umu.se">glance@acc.umu.se</a>> wrote:<br>
><br>
> So, should the right approach here be not to trust malloc returning NULL<br>
> here and we explicitly set sample to null if s->samples == 0 ?</p>
<p dir="ltr">That sounds fine, yes.</p>
<p dir="ltr">Or just initialize the fields to zero/NULL and then do that</p>
<p dir="ltr">  if (!nr)<br>
      return;</p>
<p dir="ltr">with the properly initialized state </p>
<p dir="ltr">> Another thought, taken how the current copy_samples looks, if you where<br>
> to call prepare_sample(d) after a copy_samples(s, d), which copied more<br>
> than 10 samples, too me it looks like prepare_sample would truncate the<br>
> sample list because copy_samples doesn't set dc->alloc_samples.</p>
<p dir="ltr">On mobile right now, so I can't check, but yes, initializing alloc_samples to the allocation size sounds right to me.</p>
<p dir="ltr">     Linus</p>