Re: [PATCH] Remove needless memsets after calloc

Alexander Strasser <[email protected]>
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <[email protected]>
Hi Michael!

On 2018-01-01 13:39 -0500, Michael McConville wrote:
> 
> Unless, I’m missing something obvious, this is pretty self-explanatory.

You are not missing anything AFAICT.

Seem to be oversights from SVN commit r18559 , but they may
be security relevant. I cannot say for sure, because I did
not fully analyze these code paths and all possible memset
implementations.

Either way I believe it's better to remove those memset calls.

Committed your patch.


>Calloc zeroes memory, so there’s no need to re-zero it, and modern compilers often miss this optimization.

From a quick glance, those don't seem important for performance.


Thank you for your contribution!

  Alexander

> 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++) {
_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.