home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / f2csrc.zip / f2csrc / src / memset.c < prev    next >
Text File  |  1994-01-29  |  2KB  |  67 lines

  1. /****************************************************************
  2. Copyright 1990 by AT&T Bell Laboratories and Bellcore.
  3.  
  4. Permission to use, copy, modify, and distribute this software
  5. and its documentation for any purpose and without fee is hereby
  6. granted, provided that the above copyright notice appear in all
  7. copies and that both that the copyright notice and this
  8. permission notice and warranty disclaimer appear in supporting
  9. documentation, and that the names of AT&T Bell Laboratories or
  10. Bellcore or any of their entities not be used in advertising or
  11. publicity pertaining to distribution of the software without
  12. specific, written prior permission.
  13.  
  14. AT&T and Bellcore disclaim all warranties with regard to this
  15. software, including all implied warranties of merchantability
  16. and fitness.  In no event shall AT&T or Bellcore be liable for
  17. any special, indirect or consequential damages or any damages
  18. whatsoever resulting from loss of use, data or profits, whether
  19. in an action of contract, negligence or other tortious action,
  20. arising out of or in connection with the use or performance of
  21. this software.
  22. ****************************************************************/
  23.  
  24. /* This is for the benefit of people whose systems don't provide
  25.  * memset, memcpy, and memcmp.  If yours is such a system, adjust
  26.  * the makefile by adding memset.o to the "OBJECTS =" assignment.
  27.  * WARNING: the memcpy below is adequate for f2c, but is not a
  28.  * general memcpy routine (which must correctly handle overlapping
  29.  * fields).
  30.  */
  31.  
  32.  int
  33. memcmp(s1, s2, n)
  34.  register char *s1, *s2;
  35.  int n;
  36. {
  37.     register char *se;
  38.  
  39.     for(se = s1 + n; s1 < se; s1++, s2++)
  40.         if (*s1 != *s2)
  41.             return *s1 - *s2;
  42.     return 0;
  43.     }
  44.  
  45.  char *
  46. memcpy(s1, s2, n)
  47.  register char *s1, *s2;
  48.  int n;
  49. {
  50.     register char *s0 = s1, *se = s1 + n;
  51.  
  52.     while(s1 < se)
  53.         *s1++ = *s2++;
  54.     return s0;
  55.     }
  56.  
  57. memset(s, c, n)
  58.  register char *s;
  59.  register int c;
  60.  int n;
  61. {
  62.     register char *se = s + n;
  63.  
  64.     while(s < se)
  65.         *s++ = c;
  66.     }
  67.