Re: to be effcient or not to be efficient

Steve Lhomme <[email protected]>
Newsgroups gmane.comp.multimedia.media-api
Message-ID <[email protected]>
Tuukka Toivonen wrote:

> If the vtable is set up by the API library (as opposed to a specific
> codec/filter) it might be nicer to set unimplemented functions to
> some dummy functions which just return an error instead of NULL; otherwise
> the caller has to always check whether a pointer is NULL before calling the
> function.
> 
> There might then be another function for checking whether a function is
> implemented (if a codec/filter wants to really know if a function is
> implemented or returning error for some other reason).
> 
> If the vtable is set up by codec, using NULLs for unimplemented calls might
> be better because that makes the codec simpler.

Yes.

And as this vtable is exchanged on init, the receiver (that will call 
the callbacks) can check for NULL values he would like to use at this 
time. And act accordingly in the future (instead of checking for NULL 
every time).

(in C, set a internal callback to this or that function depending on 
what the peer can do or not
in C++ instanciate this or that object depending on what the peer can do 
or not)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.