botch.c 600 B

12345678910111213141516171819202122232425
  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. /* botch - write garbage over a chunk of memory, useful if you want
  7. to check if freed memory is used inappopriately.
  8. */
  9. #include <assert.h>
  10. #include "in_all.h"
  11. EXPORT
  12. botch(ptr, n)
  13. char *ptr;
  14. int n;
  15. {
  16. assert((long)ptr % sizeof (long) == 0);
  17. while (n >= sizeof (long)) {
  18. /* high-speed botch loop */
  19. *(long *)ptr = 025252525252L;
  20. ptr += sizeof (long), n -= sizeof (long);
  21. }
  22. while (n--) *ptr++ = '\252';
  23. }