author | zecke <zecke> | 2004-09-18 16:43:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-18 16:43:47 (UTC) |
commit | c81e90d0f6c0feec1443d711833ea382a1c10ec6 (patch) (unidiff) | |
tree | 7390346761cfbceee0abccb51a80e30898f54f3b | |
parent | fa5c8471c3053dfc8d9742426faa569b3aa03d71 (diff) | |
download | opie-c81e90d0f6c0feec1443d711833ea382a1c10ec6.zip opie-c81e90d0f6c0feec1443d711833ea382a1c10ec6.tar.gz opie-c81e90d0f6c0feec1443d711833ea382a1c10ec6.tar.bz2 |
A proposal for making the memory copy functions build with g++3.4.2.
Please review the patch, specially the casts it makes, and also
the boundaries and sizes.
-Shouldn't we use unsigned char* instead of char*. For arm it is already unsigned?
-Check again the casts
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index b55750a..15c611f 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -46,38 +46,66 @@ | |||
46 | 46 | ||
47 | // 180 deg rot: copy a line from src to dst reversed | 47 | // 180 deg rot: copy a line from src to dst reversed |
48 | 48 | ||
49 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 49 | /* |
50 | * This code relies the len be a multiply of 16bit | ||
51 | */ | ||
52 | static inline void memcpy_rev ( void *_dst, void *_src, size_t len ) | ||
50 | { | 53 | { |
54 | /* | ||
55 | * move the source to the end | ||
56 | */ | ||
57 | char *src_c = static_cast<char*>(_src) + len; | ||
58 | |||
59 | /* | ||
60 | * as we copy by 16bit and not 8bit | ||
61 | * devide the length by two | ||
62 | */ | ||
51 | len >>= 1; | 63 | len >>= 1; |
52 | 64 | ||
53 | ((char *) src ) += ( len << 1 ); | 65 | short int* dst = static_cast<short int*>( _dst ); |
66 | short int* src = reinterpret_cast<short int*>( src_c ); | ||
54 | 67 | ||
68 | /* | ||
69 | * Increment dst after assigning | ||
70 | * Decrement src before assigning becase we move backwards | ||
71 | */ | ||
55 | while ( len-- ) | 72 | while ( len-- ) |
56 | *((short int *) dst )++ = *--((short int *) src ); | 73 | *dst++ = *--src; |
74 | |||
57 | } | 75 | } |
58 | 76 | ||
59 | // 90 deg rot: copy a column from src to dst | 77 | // 90 deg rot: copy a column from src to dst |
60 | 78 | ||
61 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 79 | static inline void memcpy_step ( void *_dst, void *_src, size_t len, size_t step ) |
62 | { | 80 | { |
81 | short int *dst = static_cast<short int*>( _dst ); | ||
82 | short int *src = static_cast<short int*>( _src ); | ||
83 | |||
63 | len >>= 1; | 84 | len >>= 1; |
85 | |||
86 | /* | ||
87 | * Copy 16bit from src to dst and move to the next address | ||
88 | */ | ||
64 | while ( len-- ) { | 89 | while ( len-- ) { |
65 | *((short int *) dst )++ = *((short int *) src ); | 90 | *dst++ = *src; |
66 | ((char *) src ) += step; | 91 | src = reinterpret_cast<short int*>(reinterpret_cast<char*>(src)+step); |
67 | } | 92 | } |
68 | } | 93 | } |
69 | 94 | ||
70 | // 270 deg rot: copy a column from src to dst reversed | 95 | // 270 deg rot: copy a column from src to dst reversed |
71 | 96 | ||
72 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 97 | static inline void memcpy_step_rev ( void *_dst, void *_src, size_t len, size_t step ) |
73 | { | 98 | { |
74 | len >>= 1; | 99 | len >>= 1; |
75 | 100 | ||
76 | ((char *) src ) += ( len * step ); | 101 | char *src_c = static_cast<char*>( _src ) + (len*step); |
102 | short int* dst = static_cast<short int*>( _dst ); | ||
103 | short int* src = reinterpret_cast<short int*>( src_c ); | ||
77 | 104 | ||
78 | while ( len-- ) { | 105 | while ( len-- ) { |
79 | ((char *) src ) -= step; | 106 | src_c -= step; |
80 | *((short int *) dst )++ = *((short int *) src ); | 107 | src = reinterpret_cast<short int*>( src_c ); |
108 | *dst++ = *src; | ||
81 | } | 109 | } |
82 | } | 110 | } |
83 | 111 | ||