mirror of
https://gitlab.com/bztsrc/posix-uefi.git
synced 2024-12-29 05:55:31 +01:00
Fixed issue #30
This commit is contained in:
parent
e316fa3f37
commit
38b537710b
1 changed files with 6 additions and 6 deletions
|
@ -33,7 +33,7 @@
|
||||||
void *memcpy(void *dst, const void *src, size_t n)
|
void *memcpy(void *dst, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
uint8_t *a=(uint8_t*)dst,*b=(uint8_t*)src;
|
uint8_t *a=(uint8_t*)dst,*b=(uint8_t*)src;
|
||||||
if(src && dst && n>0) {
|
if(src && dst && src != dst && n>0) {
|
||||||
while(n--) *a++ = *b++;
|
while(n--) *a++ = *b++;
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
|
@ -42,8 +42,8 @@ void *memcpy(void *dst, const void *src, size_t n)
|
||||||
void *memmove(void *dst, const void *src, size_t n)
|
void *memmove(void *dst, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
uint8_t *a=(uint8_t*)dst,*b=(uint8_t*)src;
|
uint8_t *a=(uint8_t*)dst,*b=(uint8_t*)src;
|
||||||
if(src && dst && n>0) {
|
if(src && dst && src != dst && n>0) {
|
||||||
if((a<b && a+n>b) || (b<a && b+n>a)) {
|
if(a>b && a<b+n) {
|
||||||
a+=n-1; b+=n-1; while(n-->0) *a--=*b--;
|
a+=n-1; b+=n-1; while(n-->0) *a--=*b--;
|
||||||
} else {
|
} else {
|
||||||
while(n--) *a++ = *b++;
|
while(n--) *a++ = *b++;
|
||||||
|
@ -64,7 +64,7 @@ void *memset(void *s, int c, size_t n)
|
||||||
int memcmp(const void *s1, const void *s2, size_t n)
|
int memcmp(const void *s1, const void *s2, size_t n)
|
||||||
{
|
{
|
||||||
uint8_t *a=(uint8_t*)s1,*b=(uint8_t*)s2;
|
uint8_t *a=(uint8_t*)s1,*b=(uint8_t*)s2;
|
||||||
if(s1 && s2 && n>0) {
|
if(s1 && s2 && s1 != s2 && n>0) {
|
||||||
while(n--) {
|
while(n--) {
|
||||||
if(*a != *b) return *a - *b;
|
if(*a != *b) return *a - *b;
|
||||||
a++; b++;
|
a++; b++;
|
||||||
|
@ -118,7 +118,7 @@ void *memrmem(const void *haystack, size_t hl, const void *needle, size_t nl)
|
||||||
|
|
||||||
char_t *strcpy(char_t *dst, const char_t *src)
|
char_t *strcpy(char_t *dst, const char_t *src)
|
||||||
{
|
{
|
||||||
if(src && dst) {
|
if(src && dst && src != dst) {
|
||||||
while(*src) {*dst++=*src++;} *dst=0;
|
while(*src) {*dst++=*src++;} *dst=0;
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
|
@ -127,7 +127,7 @@ char_t *strcpy(char_t *dst, const char_t *src)
|
||||||
char_t *strncpy(char_t *dst, const char_t *src, size_t n)
|
char_t *strncpy(char_t *dst, const char_t *src, size_t n)
|
||||||
{
|
{
|
||||||
const char_t *e = src+n;
|
const char_t *e = src+n;
|
||||||
if(src && dst && n>0) {
|
if(src && dst && src != dst && n>0) {
|
||||||
while(*src && src<e) {*dst++=*src++;} *dst=0;
|
while(*src && src<e) {*dst++=*src++;} *dst=0;
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
|
|
Loading…
Reference in a new issue