home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / bzero.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1.0 KB  |  69 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: bzero.c,v 1.5 1997/01/01 03:41:09 ldp Exp $
  4.  
  5.     Desc: ANSI C function bzero()
  6.     Lang: english
  7. */
  8. #include <proto/exec.h>
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <string.h>
  14.  
  15.     void bzero (
  16.  
  17. /*  SYNOPSIS */
  18.     void * ptr,
  19.     int    len)
  20.  
  21. /*  FUNCTION
  22.     Write len zero bytes to ptr. If len is zero, does nothing.
  23.  
  24.     INPUTS
  25.     ptr - The first byte of the area in memory to be cleared.
  26.     len - How many bytes to clear.
  27.  
  28.     RESULT
  29.  
  30.     NOTES
  31.  
  32.     EXAMPLE
  33.  
  34.     BUGS
  35.  
  36.     SEE ALSO
  37.  
  38.     INTERNALS
  39.  
  40.     HISTORY
  41.     28-10-96    ldp created
  42.  
  43. ******************************************************************************/
  44. {
  45.     UBYTE * bptr = ptr;
  46.  
  47.     while (((IPTR)bptr)&(AROS_LONGALIGN-1) && len)
  48.     {
  49.     *bptr ++ = 0;
  50.     len --;
  51.     }
  52.  
  53.     if (len > sizeof(ULONG))
  54.     {
  55.     ULONG * ulptr = (ULONG *)bptr;
  56.  
  57.     while (len > sizeof(ULONG))
  58.     {
  59.         *ulptr ++ = 0UL;
  60.         len -= sizeof(ULONG);
  61.     }
  62.     }
  63.  
  64.     while (len --)
  65.     *bptr ++ = 0;
  66.  
  67. } /* bzero */
  68.  
  69.