home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
mint
/
mntlib16.lzh
/
MNTLIB16
/
BZERO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-03
|
718b
|
41 lines
#include <stddef.h>
#include <string.h>
#include <assert.h>
#undef ODD
#define ODD(x) (((short)(x)) & 1) /* word ops are faster */
/*
* zero out a chunk efficiently
* handles odd address
*
* ++jrb bammi@dsrgsun.ces.cwru.edu
*/
void bzero(b, n)
register void * b;
register size_t n;
{
register size_t l, w;
assert((b != NULL));
if(ODD(b))
{
*(char *)b++ = (char)0;
n--;
}
l = (n >> 2); /* # of longs */
n -= (l << 2);
w = (n >> 1); /* # of words */
n -= (w << 1); /* n == # of residual bytes */
while(l--)
*((long *)b)++ = 0L;
while(w--)
*((short *)b)++ = (short)0;
while(n--)
*(char *)b++ = (char)0;
}