clear.c 590 B

12345678910111213141516171819202122232425262728
  1. /* $Header$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* clear - clear a block of memory, and try to do it fast.
  7. */
  8. #include <assert.h>
  9. #include "in_all.h"
  10. /* instead of Calloc: */
  11. EXPORT
  12. clear(ptr, n)
  13. register char *ptr;
  14. register int n;
  15. {
  16. register long *q = (long *) ptr;
  17. assert((long)q % sizeof (long) == 0);
  18. while (n >= sizeof (long)) {
  19. /* high-speed clear loop */
  20. *q++ = 0;
  21. n -= sizeof (long);
  22. }
  23. ptr = (char *) q;
  24. while (n--) *ptr++ = '\0';
  25. }