home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / libfake / memset.c < prev    next >
C/C++ Source or Header  |  1989-05-27  |  506b  |  31 lines

  1. /*
  2.  * memset - set bytes
  3.  *
  4.  * CHARBITS should be defined only if the compiler lacks "unsigned char".
  5.  * It should be a mask, e.g. 0377 for an 8-bit machine.
  6.  */
  7.  
  8. #ifndef CHARBITS
  9. #    define    UNSCHAR(c)    ((unsigned char)(c))
  10. #else
  11. #    define    UNSCHAR(c)    ((c)&CHARBITS)
  12. #endif
  13.  
  14. char *
  15. memset(s, ucharfill, size)
  16.  char * s;
  17. register int ucharfill;
  18. int size;
  19. {
  20.     register  char *scan;
  21.     register int n;
  22.     register int uc;
  23.  
  24.     scan = s;
  25.     uc = UNSCHAR(ucharfill);
  26.     for (n = size; n > 0; n--)
  27.         *scan++ = uc;
  28.  
  29.     return(s);
  30. }
  31.