[vlc-devel] [RFC 3/3] vlc_arrays: append items in amortized O(1)

Romain Vimont rom1v at videolabs.io
Fri Jul 20 11:42:27 CEST 2018


On Fri, Jul 20, 2018 at 11:36:41AM +0200, Filip Roséen wrote:
> > > Your tests should also assert on the return-code for functions which
> > > may fail.
> > 
> > I could, but I didn't do it because their failure would be triggered by
> > the following asserts anyway (e.g. if append() fails, count() will be
> > incorrect). And it would just add explicit assertions about
> > out-of-memory.
> 
> We have other tests using `asserts` in some places, and tests that
> even `assert` that memory-allocation succeeds. The reason is precisely
> as you pointed out: if *append* fails, *count* will be flagged as the
> culprit.
>
> Even though you might know that the function will only fail due to a
> memory allocation, who knows what changes to the function will come in
> the future (if any)? Better safe than sorry, imo.

OK, convinced. :)


More information about the vlc-devel mailing list