[Live-devel] Enumerate all 'clients' and memory leak

Ross Finlayson finlayson at live555.com
Thu Sep 20 06:44:46 PDT 2012


> And one more question, in the samples and the library itself many places in the
> code looks like this:
> 
>  RTSPClient* rtspClient = ourRTSPClient::createNew(env, rtspURL,
> RTSP_CLIENT_VERBOSITY_LEVEL, progName);
> 
>  if (rtspClient == NULL) {
> 
> createNew() just a wrapper over the standard operator new (not overloaded, not a
> `nothrow` version). But according the c++ standard operator new is never return
> NULL, but throws bad_alloc on error. Why we need to check the return value? 

Yes, you're correct - in this case, the test for "rtspClient == NULL" is not needed, and could be removed.

Note, however, that not all "createNew()" functions are simply wrappers around operator new.  "RTSPServer::createNew()", for example, is not.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120920/5037da69/attachment.html>


More information about the live-devel mailing list