[Live-devel] [patch] use const_cast instead of C casting

Ross Finlayson finlayson+mobile at live555.com
Tue Jul 8 09:24:39 PDT 2008


This is one patch that I won't be adding, because I want the code to  
work even with older compilers that might not understand  
"const_char" ( or even templates).

         Ross.
----------
Sent from my jesusPhone


On Jul 8, 2008, at 9:03 AM, Erik Hovland <erik at hovland.org> wrote:

> In C++ it is preferred to control constness by using const_cast  
> instead
> of the C casting syntax. This patch does that in a couple of places.
>
> E
>
> ---
>
> liveMedia/QuickTimeGenericRTPSource.cpp |    2 +-
> liveMedia/SimpleRTPSource.cpp           |    2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/liveMedia/QuickTimeGenericRTPSource.cpp b/liveMedia/ 
> QuickTimeGenericRTPSource.cpp
> index eff16ea..4bbe5d3 100644
> --- a/liveMedia/QuickTimeGenericRTPSource.cpp
> +++ b/liveMedia/QuickTimeGenericRTPSource.cpp
> @@ -74,7 +74,7 @@ QuickTimeGenericRTPSource
>
> QuickTimeGenericRTPSource::~QuickTimeGenericRTPSource() {
>   delete[] qtState.sdAtom;
> -  delete[] (char*)fMIMEtypeString;
> +  delete[] const_cast<char*>(fMIMEtypeString);
> }
>
> Boolean QuickTimeGenericRTPSource
> diff --git a/liveMedia/SimpleRTPSource.cpp b/liveMedia/ 
> SimpleRTPSource.cpp
> index fcfdfb5..d41fe0b 100644
> --- a/liveMedia/SimpleRTPSource.cpp
> +++ b/liveMedia/SimpleRTPSource.cpp
> @@ -49,7 +49,7 @@ SimpleRTPSource
> }
>
> SimpleRTPSource::~SimpleRTPSource() {
> -  delete[] (char*)fMIMEtypeString;
> +  delete[] const_cast<char*>(fMIMEtypeString);
> }
>
> Boolean SimpleRTPSource
>
> -- 
> Erik Hovland
> mail: erik at hovland.org
> web: http://hovland.org/
> PGP/GPG public key available on request
>
> _______________________________________________
> live-devel mailing list
> live-devel at lists.live555.com
> http://lists.live555.com/mailman/listinfo/live-devel
>


More information about the live-devel mailing list