[vlc-commits] freetype: use vlc_alloc helper

Thomas Guillem git at videolan.org
Sat Nov 11 19:00:22 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Sat Nov 11 18:50:10 2017 +0100| [f7e6bd53c4658e04dc52db71d106fada64ba35fe] | committer: Thomas Guillem

freetype: use vlc_alloc helper

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

 modules/text_renderer/freetype/fonts/dwrite.cpp |  2 +-
 modules/text_renderer/freetype/fonts/win32.c    |  2 +-
 modules/text_renderer/freetype/freetype.c       |  2 +-
 modules/text_renderer/freetype/text_layout.c    | 16 ++++++++--------
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/modules/text_renderer/freetype/fonts/dwrite.cpp b/modules/text_renderer/freetype/fonts/dwrite.cpp
index addc91a326..018a0b38dd 100644
--- a/modules/text_renderer/freetype/fonts/dwrite.cpp
+++ b/modules/text_renderer/freetype/fonts/dwrite.cpp
@@ -505,7 +505,7 @@ static char *DWrite_Fallback( filter_t *p_filter, const char *psz_family,
         goto done;
     }
 
-    pwsz_buffer = ( wchar_t * ) malloc( ( i_string_length + 1 ) * sizeof( *pwsz_buffer ) );
+    pwsz_buffer = ( wchar_t * ) vlc_alloc( ( i_string_length + 1 ), sizeof( *pwsz_buffer ) );
     if( unlikely( !pwsz_buffer ) )
         goto done;
 
diff --git a/modules/text_renderer/freetype/fonts/win32.c b/modules/text_renderer/freetype/fonts/win32.c
index 39fa523efc..73d4939f07 100644
--- a/modules/text_renderer/freetype/fonts/win32.c
+++ b/modules/text_renderer/freetype/fonts/win32.c
@@ -310,7 +310,7 @@ static TCHAR *GetFullEnglishName( const ENUMLOGFONTEX *lpelfe )
         goto done;
 
     int i_length_in_wchars = i_name_length / 2;
-    wchar_t *psz_name = malloc( ( i_length_in_wchars + 1 ) * sizeof( *psz_name ) );
+    wchar_t *psz_name = vlc_alloc( i_length_in_wchars + 1, sizeof( *psz_name ) );
 
     if( !psz_name )
         goto done;
diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c
index 269dbd7bc3..bc55b9bcdd 100644
--- a/modules/text_renderer/freetype/freetype.c
+++ b/modules/text_renderer/freetype/freetype.c
@@ -302,7 +302,7 @@ static int LoadFontsFromAttachments( filter_t *p_filter )
         return VLC_EGENERIC;
 
     p_sys->i_font_attachments = 0;
-    p_sys->pp_font_attachments = malloc( i_attachments_cnt * sizeof(*p_sys->pp_font_attachments));
+    p_sys->pp_font_attachments = vlc_alloc( i_attachments_cnt, sizeof(*p_sys->pp_font_attachments));
     if( !p_sys->pp_font_attachments )
     {
         for( int i = 0; i < i_attachments_cnt; ++i )
diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
index 9ba393b7f9..b2991a8c9a 100644
--- a/modules/text_renderer/freetype/text_layout.c
+++ b/modules/text_renderer/freetype/text_layout.c
@@ -253,11 +253,11 @@ static paragraph_t *NewParagraph( filter_t *p_filter,
 
     p_paragraph->i_size = i_size;
     p_paragraph->p_code_points =
-            malloc( i_size * sizeof( *p_paragraph->p_code_points ) );
+            vlc_alloc( i_size, sizeof( *p_paragraph->p_code_points ) );
     p_paragraph->pi_glyph_indices =
-            malloc( i_size * sizeof( *p_paragraph->pi_glyph_indices ) );
+            vlc_alloc( i_size, sizeof( *p_paragraph->pi_glyph_indices ) );
     p_paragraph->pp_styles =
-            malloc( i_size * sizeof( *p_paragraph->pp_styles ) );
+            vlc_alloc( i_size, sizeof( *p_paragraph->pp_styles ) );
     p_paragraph->pp_faces =
             calloc( i_size, sizeof( *p_paragraph->pp_faces ) );
     p_paragraph->pi_run_ids =
@@ -293,16 +293,16 @@ static paragraph_t *NewParagraph( filter_t *p_filter,
     }
 
 #ifdef HAVE_HARFBUZZ
-    p_paragraph->p_scripts = malloc( i_size * sizeof( *p_paragraph->p_scripts ) );
+    p_paragraph->p_scripts = vlc_alloc( i_size, sizeof( *p_paragraph->p_scripts ) );
     if( !p_paragraph->p_scripts )
         goto error;
 #endif
 
 #ifdef HAVE_FRIBIDI
-    p_paragraph->p_levels = malloc( i_size * sizeof( *p_paragraph->p_levels ) );
-    p_paragraph->p_types = malloc( i_size * sizeof( *p_paragraph->p_types ) );
+    p_paragraph->p_levels = vlc_alloc( i_size, sizeof( *p_paragraph->p_levels ) );
+    p_paragraph->p_types = vlc_alloc( i_size, sizeof( *p_paragraph->p_types ) );
     p_paragraph->pi_reordered_indices =
-            malloc( i_size * sizeof( *p_paragraph->pi_reordered_indices ) );
+            vlc_alloc( i_size, sizeof( *p_paragraph->pi_reordered_indices ) );
 
     if( !p_paragraph->p_levels || !p_paragraph->p_types
      || !p_paragraph->pi_reordered_indices )
@@ -843,7 +843,7 @@ static int ShapeParagraphFriBidi( filter_t *p_filter, paragraph_t *p_paragraph )
     }
 
     FriBidiJoiningType *p_joining_types =
-            malloc( p_paragraph->i_size * sizeof( *p_joining_types ) );
+            vlc_alloc( p_paragraph->i_size, sizeof( *p_joining_types ) );
     if( !p_joining_types )
         return VLC_ENOMEM;
 



More information about the vlc-commits mailing list