[vlc-commits] [Git][videolan/vlc][master] 2 commits: codec: dvbsub: refactor p_sys allocation

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Jul 29 17:53:28 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
35da430c by Alexandre Janniaux at 2023-07-29T17:41:07+00:00
codec: dvbsub: refactor p_sys allocation

malloc returns a `void*` type which doesn't need a cast to a different
pointer type. In addition, both the allocation and the success check was
done at the same time, reducing the readability of the code.

- - - - -
6b48cb21 by Alexandre Janniaux at 2023-07-29T17:41:07+00:00
dvbsub: refactor to end label

- - - - -


1 changed file:

- modules/codec/dvbsub.c


Changes:

=====================================
modules/codec/dvbsub.c
=====================================
@@ -415,10 +415,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
     {
         Flush( p_dec );
         if( p_block->i_flags & BLOCK_FLAG_CORRUPTED )
-        {
-            block_Release( p_block );
-            return VLCDEC_SUCCESS;
-        }
+            goto end;
     }
 
     /* configure for SD res in case DDS is not present */
@@ -434,8 +431,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
          * don't complain too loudly. */
         msg_Warn( p_dec, "non dated subtitle" );
 #endif
-        block_Release( p_block );
-        return VLCDEC_SUCCESS;
+        goto end;
     }
 
     bs_init( &p_sys->bs, p_block->p_buffer, p_block->i_buffer );
@@ -443,15 +439,13 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
     if( bs_read( &p_sys->bs, 8 ) != 0x20 ) /* Data identifier */
     {
         msg_Dbg( p_dec, "invalid data identifier" );
-        block_Release( p_block );
-        return VLCDEC_SUCCESS;
+        goto end;
     }
 
     if( bs_read( &p_sys->bs, 8 ) ) /* Subtitle stream id */
     {
         msg_Dbg( p_dec, "invalid subtitle stream id" );
-        block_Release( p_block );
-        return VLCDEC_SUCCESS;
+        goto end;
     }
 
 #ifdef DEBUG_DVBSUB
@@ -470,8 +464,7 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
     if( ( i_sync_byte & 0x3f ) != 0x3f ) /* End marker */
     {
         msg_Warn( p_dec, "end marker not found (corrupted subtitle ?)" );
-        block_Release( p_block );
-        return VLCDEC_SUCCESS;
+        goto end;
     }
 
     /* Check if the page is to be displayed */
@@ -482,8 +475,8 @@ static int Decode( decoder_t *p_dec, block_t *p_block )
             decoder_QueueSub( p_dec, p_spu );
     }
 
-    block_Release( p_block );
-
+end:
+    block_Release(p_block);
     return VLCDEC_SUCCESS;
 }
 
@@ -1707,7 +1700,8 @@ static int OpenEncoder( vlc_object_t *p_this )
     }
 
     /* Allocate the memory needed to store the decoder's structure */
-    if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
+    p_sys = malloc(sizeof(encoder_sys_t));
+    if (p_sys == NULL)
         return VLC_ENOMEM;
     p_enc->p_sys = p_sys;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/60b6df1f390e8ce7e5c1fede38e3e5ffcb729914...6b48cb210192aafe8707e32c06868fcb926067cc

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/60b6df1f390e8ce7e5c1fede38e3e5ffcb729914...6b48cb210192aafe8707e32c06868fcb926067cc
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list