memset.c

Go to the documentation of this file.
00001 /****************************************************************
00002 Copyright 1990, 2000 by AT&T, Lucent Technologies and Bellcore.
00003 
00004 Permission to use, copy, modify, and distribute this software
00005 and its documentation for any purpose and without fee is hereby
00006 granted, provided that the above copyright notice appear in all
00007 copies and that both that the copyright notice and this
00008 permission notice and warranty disclaimer appear in supporting
00009 documentation, and that the names of AT&T, Bell Laboratories,
00010 Lucent or Bellcore or any of their entities not be used in
00011 advertising or publicity pertaining to distribution of the
00012 software without specific, written prior permission.
00013 
00014 AT&T, Lucent and Bellcore disclaim all warranties with regard to
00015 this software, including all implied warranties of
00016 merchantability and fitness.  In no event shall AT&T, Lucent or
00017 Bellcore be liable for any special, indirect or consequential
00018 damages or any damages whatsoever resulting from loss of use,
00019 data or profits, whether in an action of contract, negligence or
00020 other tortious action, arising out of or in connection with the
00021 use or performance of this software.
00022 ****************************************************************/
00023 
00024 /* This is for the benefit of people whose systems don't provide
00025  * memset, memcpy, and memcmp.  If yours is such a system, adjust
00026  * the makefile by adding memset.o to the "OBJECTS =" assignment.
00027  * WARNING: the memcpy below is adequate for f2c, but is not a
00028  * general memcpy routine (which must correctly handle overlapping
00029  * fields).
00030  */
00031 
00032  int
00033 #ifdef KR_headers
00034 memcmp(s1, s2, n) char *s1, *s2; int n;
00035 #else
00036 memcmp(char *s1, char *s2, int n)
00037 #endif
00038 {
00039         char *se;
00040 
00041         for(se = s1 + n; s1 < se; s1++, s2++)
00042                 if (*s1 != *s2)
00043                         return *s1 - *s2;
00044         return 0;
00045         }
00046 
00047  char *
00048 #ifdef KR_headers
00049 memcpy(s1, s2, n) char *s1, *s2; int n;
00050 #else
00051 memcpy(char *s1, char *s2, int n)
00052 #endif
00053 {
00054         char *s0 = s1, *se = s1 + n;
00055 
00056         while(s1 < se)
00057                 *s1++ = *s2++;
00058         return s0;
00059         }
00060 
00061  void
00062 #ifdef KR_headers
00063 memset(s, c, n) char *s; int c, n;
00064 #else
00065 memset(char *s, int c, int n)
00066 #endif
00067 {
00068         char *se = s + n;
00069 
00070         while(s < se)
00071                 *s++ = c;
00072         }

Generated on Sun Mar 4 15:03:44 2007 for Scilab [trunk] by  doxygen 1.5.1