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