[vlc-devel] commit: Simplification ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat May 10 22:21:02 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Sat May 10 22:58:31 2008 +0300| [7793bdcbd3a77917c4dec40c737a8b04017430c5]

Simplification

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7793bdcbd3a77917c4dec40c737a8b04017430c5
---

 src/misc/messages.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/misc/messages.c b/src/misc/messages.c
index 100d61e..38752e9 100644
--- a/src/misc/messages.c
+++ b/src/misc/messages.c
@@ -650,14 +650,13 @@ void msg_StackAdd( const char *psz_message, ... )
         p_ctx->psz_message = psz_tmp;
     else
     {
-        char *psz_old = malloc( strlen( p_ctx->psz_message ) + 1 );
-        memcpy( psz_old, p_ctx->psz_message, strlen( p_ctx->psz_message ) + 1 );
-        p_ctx->psz_message = realloc( p_ctx->psz_message,
-                                      strlen( p_ctx->psz_message ) +
-                                      /* ':', ' ', '0' */
-                                      strlen( psz_tmp ) + 3 );
-        sprintf( p_ctx->psz_message, "%s: %s", psz_tmp, psz_old );
-        free( psz_tmp ); free( psz_old );
+        char *psz_new;
+        if( asprintf( &psz_new, "%s: %s", psz_tmp, p_ctx->psz_message ) == -1 )
+            psz_new = NULL;
+
+        free( p_ctx->psz_message );
+        p_ctx->psz_message = psz_new;
+        free( psz_tmp );
     }
 }
 




More information about the vlc-devel mailing list