Patch by Vasilis Kaoutsis: Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22518 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
* Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||||
** Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -13,55 +14,56 @@ typedef int word;
|
|||||||
#define lsize sizeof(word)
|
#define lsize sizeof(word)
|
||||||
#define lmask (lsize - 1)
|
#define lmask (lsize - 1)
|
||||||
|
|
||||||
void *
|
|
||||||
memmove(void *dest, void const *src, size_t count)
|
void*
|
||||||
|
memmove(void* dest, void const* src, size_t count)
|
||||||
{
|
{
|
||||||
char *d = (char *)dest;
|
char* d = (char*)dest;
|
||||||
const char *s = (const char *)src;
|
const char* s = (const char*)src;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(count == 0 || dest == src)
|
if (count == 0 || dest == src)
|
||||||
return dest;
|
return dest;
|
||||||
|
|
||||||
if((long)d < (long)s) {
|
if ((long)d < (long)s) {
|
||||||
if(((long)d | (long)s) & lmask) {
|
if (((long)d | (long)s) & lmask) {
|
||||||
// src and/or dest do not align on word boundary
|
// src and/or dest do not align on word boundary
|
||||||
if((((long)d ^ (long)s) & lmask) || (count < lsize))
|
if ((((long)d ^ (long)s) & lmask) || (count < lsize))
|
||||||
len = count; // copy the rest of the buffer with the byte mover
|
len = count; // copy the rest of the buffer with the byte mover
|
||||||
else
|
else
|
||||||
len = lsize - ((long)d & lmask); // move the ptrs up to a word boundary
|
len = lsize - ((long)d & lmask); // move the ptrs up to a word boundary
|
||||||
|
|
||||||
count -= len;
|
count -= len;
|
||||||
for(; len > 0; len--)
|
for (; len > 0; len--)
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
for(len = count / lsize; len > 0; len--) {
|
for (len = count / lsize; len > 0; len--) {
|
||||||
*(word *)d = *(word *)s;
|
*(word*)d = *(word*)s;
|
||||||
d += lsize;
|
d += lsize;
|
||||||
s += lsize;
|
s += lsize;
|
||||||
}
|
}
|
||||||
for(len = count & lmask; len > 0; len--)
|
for (len = count & lmask; len > 0; len--)
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
} else {
|
} else {
|
||||||
d += count;
|
d += count;
|
||||||
s += count;
|
s += count;
|
||||||
if(((long)d | (long)s) & lmask) {
|
if (((long)d | (long)s) & lmask) {
|
||||||
// src and/or dest do not align on word boundary
|
// src and/or dest do not align on word boundary
|
||||||
if((((long)d ^ (long)s) & lmask) || (count <= lsize))
|
if ((((long)d ^ (long)s) & lmask) || (count <= lsize))
|
||||||
len = count;
|
len = count;
|
||||||
else
|
else
|
||||||
len = ((long)d & lmask);
|
len = ((long)d & lmask);
|
||||||
|
|
||||||
count -= len;
|
count -= len;
|
||||||
for(; len > 0; len--)
|
for (; len > 0; len--)
|
||||||
*--d = *--s;
|
*--d = *--s;
|
||||||
}
|
}
|
||||||
for(len = count / lsize; len > 0; len--) {
|
for (len = count / lsize; len > 0; len--) {
|
||||||
d -= lsize;
|
d -= lsize;
|
||||||
s -= lsize;
|
s -= lsize;
|
||||||
*(word *)d = *(word *)s;
|
*(word*)d = *(word*)s;
|
||||||
}
|
}
|
||||||
for(len = count & lmask; len > 0; len--)
|
for (len = count & lmask; len > 0; len--)
|
||||||
*--d = *--s;
|
*--d = *--s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,4 +71,3 @@ memmove(void *dest, void const *src, size_t count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
* Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||||
** Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
char *
|
char*
|
||||||
strchr(const char *s, int c)
|
strchr(const char* s, int c)
|
||||||
{
|
{
|
||||||
for(; *s != (char) c; ++s)
|
for (; *s != (char)c; ++s)
|
||||||
if (*s == '\0')
|
if (*s == '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
return (char *)s;
|
return (char*)s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char*
|
||||||
index(const char *s, int c)
|
index(const char* s, int c)
|
||||||
{
|
{
|
||||||
return strchr(s, c);
|
return strchr(s, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user