Fix memmove with new size_t typedef, thanks DevHC for reporting

This commit is contained in:
Thilo Schulz 2011-02-08 21:27:45 +00:00
parent eb11388cac
commit c257dc2cfa

View file

@ -272,18 +272,29 @@ int toupper( int c ) {
return c; return c;
} }
void *memmove( void *dest, const void *src, size_t count ) { void *memmove(void *dest, const void *src, size_t count)
int i; {
size_t i;
if ( dest > src ) { if(count)
for ( i = count-1 ; i >= 0 ; i-- ) { {
((char *)dest)[i] = ((char *)src)[i]; if(dest > src)
{
i = count - 1;
do
{
((char *) dest)[i] = ((char *) src)[i];
i--;
} while(i > 0);
} }
} else { else
for ( i = 0 ; i < count ; i++ ) { {
((char *)dest)[i] = ((char *)src)[i]; for(i = 0; i < count; i++)
((char *) dest)[i] = ((char *) src)[i];
} }
} }
return dest; return dest;
} }