* You should not use this function to access IO space, use memcpy_toio()
* or memcpy_fromio() instead.
*/
-void * memcpy(void *dest, const void *src, size_t count)
+void* memcpy(void* dest, const void* src, size_t count)
{
- unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
+ unsigned long* dl = (unsigned long*)dest, *sl = (unsigned long*)src;
char *d8, *s8;
if (src == dest)
/* copy the reset one byte at a time */
d8 = (char *)dl;
s8 = (char *)sl;
- while (count--)
+ while (count--) {
*d8++ = *s8++;
-
+ }
return dest;
}
*
* Do not use memset() to access IO space, use memset_io() instead.
*/
-void * memset(void * s,int c,size_t count)
+void* memset(void* s, int c, size_t count)
{
- unsigned long *sl = (unsigned long *) s;
+ unsigned long* sl = (unsigned long*) s;
unsigned long cl = 0;
- char *s8;
+ char* s8;
int i;
/* do it one word at a time (32 bits or 64 bits) while possible */
}
}
/* fill 8 bits at a time */
- s8 = (char *)sl;
- while (count--)
+ s8 = (char*)sl;
+ while (count--) {
*s8++ = c;
-
+ }
return s;
}
* @dest: Where to copy the string to
* @src: Where to copy the string from
*/
-char * strcpy(char * dest,const char *src)
+char* strcpy(char* dest, const char* src)
{
- char *tmp = dest;
+ char* tmp = dest;
- while ((*dest++ = *src++) != '\0')
+ while ((*dest++ = *src++) != '\0') {
/* nothing */;
+ }
return tmp;
}
* However, the result is not %NUL-terminated if the source exceeds
* @count bytes.
*/
-char * strncpy(char * dest,const char *src,size_t count)
+char* strncpy(char* dest, const char* src, size_t count)
{
- char *tmp = dest;
+ char* tmp = dest;
- while (count-- && (*dest++ = *src++) != '\0')
+ while (count-- && (*dest++ = *src++) != '\0') {
/* nothing */;
-
+ }
return tmp;
}
* @cs: One string
* @ct: Another string
*/
-int strcmp(const char * cs,const char * ct)
+int strcmp(const char* cs, const char* ct)
{
register signed char __res;
while (1) {
- if ((__res = *cs - *ct++) != 0 || !*cs++)
+ if ((__res = *cs - *ct++) != 0 || !*cs++) {
break;
+ }
}
-
return __res;
}
* @ct: Another string
* @count: The maximum number of bytes to compare
*/
-int strncmp(const char * cs,const char * ct,size_t count)
+int strncmp(const char* cs, const char* ct, size_t count)
{
register signed char __res = 0;
while (count) {
- if ((__res = *cs - *ct++) != 0 || !*cs++)
+ if ((__res = *cs - *ct++) != 0 || !*cs++) {
break;
+ }
count--;
}
* @s: The string to be searched
* @c: The character to search for
*/
-char * strchr(const char * s, int c)
+char* strchr(const char* s, int c)
{
- for(; *s != (char) c; ++s)
- if (*s == '\0')
+ for(; *s != (char) c; ++s) {
+ if (*s == '\0') {
return NULL;
+ }
+ }
return (char *) s;
}
* strlen - Find the length of a string
* @s: The string to be sized
*/
-size_t strlen(const char * s)
+size_t strlen(const char* s)
{
- const char *sc;
+ const char* sc;
- for (sc = s; *sc != '\0'; ++sc)
+ for (sc = s; *sc != '\0'; ++sc) {
/* nothing */;
+ }
return sc - s;
}
* @s: The string to be searched
* @c: The character to search for
*/
-char * strrchr(const char * s, int c)
+char* strrchr(const char* s, int c)
{
- const char *p = s + strlen(s);
- do {
- if (*p == (char)c)
- return (char *)p;
- } while (--p >= s);
- return NULL;
+ const char* p = s + strlen(s);
+ do {
+ if (*p == (char)c) {
+ return (char *)p;
+ }
+ } while (--p >= s);
+ return NULL;
}
/**
* @s: The string to be sized
* @count: The maximum number of bytes to search
*/
-size_t strnlen(const char * s, size_t count)
+size_t strnlen(const char* s, size_t count)
{
- const char *sc;
+ const char* sc;
- for (sc = s; count-- && *sc != '\0'; ++sc)
+ for (sc = s; count-- && *sc != '\0'; ++sc) {
/* nothing */;
+ }
return sc - s;
}