Now calls memset (avoids code duplication).
This commit is contained in:
parent
5ed58ad13e
commit
c685985dbf
|
@ -1,52 +1,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* This is a _fast_ block move routine! */
|
||||
|
||||
void bcopy(const void *s1,void *s2,size_t n)
|
||||
{ size_t m;
|
||||
if(!n)
|
||||
return;
|
||||
if(s2<s1)
|
||||
{ if(n>15)
|
||||
{ if((long)s1&1)
|
||||
{ *((char *)s2)++=*((char *)s1)++;
|
||||
n--; }
|
||||
if(!((long)s2&1))
|
||||
{ if((long)s1&2)
|
||||
{ *((short *)s2)++=*((short *)s1)++;
|
||||
n-=2; }
|
||||
for(m=n/(8*sizeof(long));m;--m)
|
||||
{ *((long *)s2)++=*((long *)s1)++; *((long *)s2)++=*((long *)s1)++;
|
||||
*((long *)s2)++=*((long *)s1)++; *((long *)s2)++=*((long *)s1)++;
|
||||
*((long *)s2)++=*((long *)s1)++; *((long *)s2)++=*((long *)s1)++;
|
||||
*((long *)s2)++=*((long *)s1)++; *((long *)s2)++=*((long *)s1)++; }
|
||||
n&=8*sizeof(long)-1;
|
||||
for(m=n/sizeof(long);m;--m)
|
||||
*((long *)s2)++=*((long *)s1)++;
|
||||
n&=sizeof(long)-1; }
|
||||
if(!n) return;
|
||||
} do;while(*((char *)s2)++=*((char *)s1)++,--n);
|
||||
}else
|
||||
{ (char *)s1+=n;
|
||||
(char *)s2+=n;
|
||||
if(n>15)
|
||||
{ if((long)s1&1)
|
||||
{ *--((char *)s2)=*--((char *)s1);
|
||||
n--; }
|
||||
if(!((long)s2&1))
|
||||
{ if((long)s1&2)
|
||||
{ *--((short *)s2)=*--((short *)s1);
|
||||
n-=2; }
|
||||
for(m=n/(8*sizeof(long));m;--m)
|
||||
{ *--((long *)s2)=*--((long *)s1); *--((long *)s2)=*--((long *)s1);
|
||||
*--((long *)s2)=*--((long *)s1); *--((long *)s2)=*--((long *)s1);
|
||||
*--((long *)s2)=*--((long *)s1); *--((long *)s2)=*--((long *)s1);
|
||||
*--((long *)s2)=*--((long *)s1); *--((long *)s2)=*--((long *)s1); }
|
||||
n&=8*sizeof(long)-1;
|
||||
for(m=n/sizeof(long);m;--m)
|
||||
*--((long *)s2)=*--((long *)s1);
|
||||
n&=sizeof(long)-1; }
|
||||
if(!n) return;
|
||||
} do;while(*--((char *)s2)=*--((char *)s1),--n);
|
||||
}
|
||||
{
|
||||
memcpy(s2, s1, n);
|
||||
}
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
#include <string.h>
|
||||
#include <memory.h>
|
||||
|
||||
void bzero(void *b,size_t n)
|
||||
{ size_t m;
|
||||
if(!n)
|
||||
return;
|
||||
if(n>15)
|
||||
{ if((long)b&1)
|
||||
{ *((char *)b)++=0;
|
||||
n--; }
|
||||
if((long)b&2)
|
||||
{ *((short *)b)++=0;
|
||||
n-=2; }
|
||||
for(m=n/(8*sizeof(long));m;--m)
|
||||
{ *((long *)b)++=0; *((long *)b)++=0; *((long *)b)++=0; *((long *)b)++=0;
|
||||
*((long *)b)++=0; *((long *)b)++=0; *((long *)b)++=0; *((long *)b)++=0; }
|
||||
n&=8*sizeof(long)-1;
|
||||
for(m=n/sizeof(long);m;--m)
|
||||
*((long *)b)++=0;
|
||||
if((n&=sizeof(long)-1)==0) return;
|
||||
}
|
||||
do;while(*((char *)b)++=0,--n);
|
||||
{
|
||||
memset(b, 0, n);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue