On Thu, Jul 21, 2016 at 7:26 AM Paweł Goliński <golp...@gmail.com> wrote:

> Hi,
>
> I’m wondering how should error checking be done when it comes to using
> mlt++.
> Is there some standard way to do that?
>
>
>
The is_valid method and integer return values where, generally, 0 means
success.


>
> Example, which motivates the question:
>
> If I do something like that „Mlt::Profile profile;” in my C++ code,
> it theoretically declares and initializes a valid mlt_profile object.
>
> But looking further, it contains „mlt_profile_init(NULL);” call which can
> return
> NULL if internal calloc() fails. Which would mean that profile would not
> be a valid object,
> as „instance” member would be NULL, and any setters called will do a NULL
> pointer dereference…
>

That class is an exception...


>
> It is written in „docs/mlt++.txt” that objects may not be valid and they
> contain „is_valid()” method
> to check their validity before they’re used. But, for example, it seems
> Profile doesn’t have such a function…
>
>
We can add that method. For the past 10 years, all users of mlt++ have just
assumed the calloc had succeeded. We can add is_valid, so you can check for
that (but there are quite likely other allocations within MLT and its
dependencies that do not check allocations).

Another exception is that other MLT objects derive from mlt_properties,
which is reference-counted, but not mlt_profile.


> So, it seems, I need to check by hand if Profile’s instance is not NULL
> before using a Profile object…
> But to know that, I needed to go as deep as „mlt_profile_init()”
> declaration.
>
>
You can also call mlt_profile_init(), check its return value and if OK, and
pass it to the Mlt::Profile constructor.

I wonder then, is there is some less involved, standard way to do error
> checking?

(So I wouldn’t need to read MLT code every time I use an object, to know
> what can go wrong).
>
>
Would you like some cheese to go with that whine?


>
> Best,
> Paweł
>
>
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to