bzero.c 552 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. libc_hidden_proto(memset)
  9. void bzero(void *s, size_t n)
  10. {
  11. #if 1
  12. (void)memset(s, 0, n);
  13. #else
  14. register unsigned char *p = s;
  15. #ifdef __BCC__
  16. /* bcc can optimize the counter if it thinks it is a pointer... */
  17. register const char *np = (const char *) n;
  18. #else
  19. #define np n
  20. #endif
  21. while (np) {
  22. *p++ = 0;
  23. --np;
  24. }
  25. #endif
  26. }
  27. #undef np