[MPlayer-dev-eng] [PATCH] get rid of *void pointer arithemtic in libvo/fastmemcpy.h

Guillaume POIRIER poirierg at gmail.com
Thu Jan 25 17:01:02 CET 2007


Hi,

On 1/25/07, Reimar Doeffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
> Hello,
> On Thu, Jan 25, 2007 at 02:36:46PM +0100, Guillaume Poirier wrote:
> > The attached patch does $SUBJ.
> >
> > It was spotted by Intel's C Compiler.
> >
> > As Michael is the one who suggested that changed, unless someone
> > disagrees or gives the go ahead now, I'll apply it by tomorrow.
> >
> > Guillaume
>
> > Index: libvo/fastmemcpy.h
> > ===================================================================
> > --- libvo/fastmemcpy.h        (revision 21941)
> > +++ libvo/fastmemcpy.h        (working copy)
> > @@ -7,6 +7,7 @@
> >  #if defined(HAVE_MMX) || defined(HAVE_MMX2) || defined(HAVE_3DNOW) \
> >  /*    || defined(HAVE_SSE) || defined(HAVE_SSE2) */
> >  #include <stddef.h>
> > +#include <stdint.h>
>
> I think inttypes.h is prefered within MPlayer even if it is not (yet)
> needed here.

So you'd vote for which type? char*? int*? I don't think it matter
here though...


> Also I do not like changing the type of the parameters, the memcpy types
> are void*, too, AFAIK.

That's Correct:
void *memcpy(void *dest, const void *src, size_t n);

> Instead either cast or use a local variable with appropriate type IMO

Attached patch implements the solution with casts, with uint8_t*.

If you prefer char* or whatever else, then I can change it before committing.

Guillaume
-------------- next part --------------
Index: libvo/fastmemcpy.h
===================================================================
--- libvo/fastmemcpy.h	(revision 21941)
+++ libvo/fastmemcpy.h	(working copy)
@@ -7,6 +7,7 @@
 #if defined(HAVE_MMX) || defined(HAVE_MMX2) || defined(HAVE_3DNOW) \
 /*    || defined(HAVE_SSE) || defined(HAVE_SSE2) */
 #include <stddef.h>
+#include <inttypes.h>
 
 extern void * fast_memcpy(void * to, const void * from, size_t len);
 extern void * mem2agpcpy(void * to, const void * from, size_t len);
@@ -28,8 +29,8 @@
 	if(dstStride == srcStride)
 	{
 		if (srcStride < 0) {
-	    		src += (height-1)*srcStride;
-	    		dst += (height-1)*dstStride;
+	    		src = (uint8_t*)src + (height-1)*srcStride;
+	    		dst = (uint8_t*)dst + (height-1)*dstStride;
 	    		srcStride = -srcStride;
 		}
 
@@ -40,8 +41,8 @@
 		for(i=0; i<height; i++)
 		{
 			mem2agpcpy(dst, src, bytesPerLine);
-			src+= srcStride;
-			dst+= dstStride;
+			src = (uint8_t*)src + srcStride;
+			dst = (uint8_t*)dst + dstStride;
 		}
 	}
 
@@ -56,8 +57,8 @@
 	if(dstStride == srcStride)
 	{
 		if (srcStride < 0) {
-	    		src += (height-1)*srcStride;
-	    		dst += (height-1)*dstStride;
+	    		src = (uint8_t*)src + (height-1)*srcStride;
+	    		dst = (uint8_t*)dst + (height-1)*dstStride;
 	    		srcStride = -srcStride;
 		}
 
@@ -68,8 +69,8 @@
 		for(i=0; i<height; i++)
 		{
 			memcpy(dst, src, bytesPerLine);
-			src+= srcStride;
-			dst+= dstStride;
+			src = (uint8_t*)src + srcStride;
+			dst = (uint8_t*)dst + dstStride;
 		}
 	}
 


More information about the MPlayer-dev-eng mailing list