[MPlayer-dev-eng] [PATCH] Remove needless memsets after calloc

Michael McConville mmcco at mykolab.com
Mon Jan 1 20:39:13 EET 2018


Hi guys.

Unless, I’m missing something obvious, this is pretty self-explanatory. Calloc zeroes memory, so there’s no need to re-zero it, and modern compilers often miss this optimization.

Thanks for your time,
Michael McConville
University of Utah

Index: libmpdemux/muxer_avi.c
===================================================================
--- libmpdemux/muxer_avi.c	(revision 38012)
+++ libmpdemux/muxer_avi.c	(working copy)
@@ -120,7 +120,6 @@
     si->idx=calloc(si->idxsize, sizeof(struct avi_odmlidx_entry));
     si->riffofssize=16;
     si->riffofs=calloc((si->riffofssize+1), sizeof(off_t));
-    memset(si->riffofs, 0, sizeof(off_t)*si->riffofssize);
 
     switch(type){
     case MUXER_TYPE_VIDEO:
@@ -619,7 +618,6 @@
 
     si->superidxsize = si->superidxpos;
     si->superidx = calloc(si->superidxsize, sizeof(*si->superidx));
-    memset(si->superidx, 0, sizeof(*si->superidx) * si->superidxsize);
 
     idxpos = 0;
     for (j=0; j<si->superidxpos; j++) {


More information about the MPlayer-dev-eng mailing list