[PATCH] - avoid some memset

Marion & Christophe JAILLET christophe.jaillet at wanadoo.fr
Mon Jun 18 13:40:27 PDT 2012


Hi,

this patch removes some useless memset(..., 0, ...) of memory that has 
been calloc'ated
It also improves a bit some formating, (<type>*) --> (<type> *)

It is against :
     vcl/source/fontsubset/sft.cxx


Best regards
Christophe JAILLET
-------------- next part --------------
>From b81145830995f9808be3ebed3f451cd6befd73db Mon Sep 17 00:00:00 2001
From: Christophe Christophe Marion <christophe.jaillet at wanadoo.fr>
Date: Mon, 18 Jun 2012 22:10:27 +0200
Subject: [PATCH] Remove some useless memset(0)

---
 vcl/source/fontsubset/sft.cxx |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 26f31f2..f21ca6c 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1439,7 +1439,6 @@ static void GetKern(TrueTypeFont *ttf)
         ttf->nkern = GetUInt16(table, 2, 1);
         ttf->kerntables = (const sal_uInt8**)calloc(ttf->nkern, sizeof(sal_uInt8 *));
         assert(ttf->kerntables != 0);
-        memset(ttf->kerntables, 0, ttf->nkern * sizeof(sal_uInt8 *));
         ttf->kerntype = KT_MICROSOFT;
         ptr = table + 4;
         for( unsigned i = 0; i < ttf->nkern; ++i) {
@@ -1457,9 +1456,8 @@ static void GetKern(TrueTypeFont *ttf)
 
     if (GetUInt32(table, 0, 1) == 0x00010000) {                       /* MacOS style kern tables: fixed32 version and sal_uInt32 nTables fields */
         ttf->nkern = GetUInt32(table, 4, 1);
-        ttf->kerntables = (const sal_uInt8**)calloc(ttf->nkern, sizeof(sal_uInt8*));
+        ttf->kerntables = (const sal_uInt8**)calloc(ttf->nkern, sizeof(sal_uInt8 *));
         assert(ttf->kerntables != 0);
-        memset(ttf->kerntables, 0, ttf->nkern * sizeof(sal_uInt8 *));
         ttf->kerntype = KT_APPLE_NEW;
         ptr = table + 8;
         for( unsigned i = 0; i < ttf->nkern; ++i) {
@@ -1624,14 +1622,11 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t )
     if( t->ntables >= 128 )
         return SF_TTFORMAT;
 
-    t->tables = (const sal_uInt8**)calloc(NUM_TAGS, sizeof(sal_uInt8*));
+    t->tables = (const sal_uInt8**)calloc(NUM_TAGS, sizeof(sal_uInt8 *));
     assert(t->tables != 0);
     t->tlens = (sal_uInt32*)calloc(NUM_TAGS, sizeof(sal_uInt32));
     assert(t->tlens != 0);
 
-    memset(t->tables, 0, NUM_TAGS * sizeof(void *));
-    memset(t->tlens, 0, NUM_TAGS * sizeof(sal_uInt32));
-
     /* parse the tables */
     for (i=0; i<(int)t->ntables; i++) {
         int nIndex;
-- 
1.7.9



More information about the LibreOffice mailing list