home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / lattice / memset.c < prev    next >
C/C++ Source or Header  |  1992-02-11  |  630b  |  35 lines

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