Doxygen Source Code Documentation
memset.c
Go to the documentation of this file.00001 /**************************************************************** 00002 Copyright 1990 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 memcmp(s1, s2, n) 00034 register char *s1, *s2; 00035 int n; 00036 { 00037 register char *se; 00038 00039 for(se = s1 + n; s1 < se; s1++, s2++) 00040 if (*s1 != *s2) 00041 return *s1 - *s2; 00042 return 0; 00043 } 00044 00045 char * 00046 memcpy(s1, s2, n) 00047 register char *s1, *s2; 00048 int n; 00049 { 00050 register char *s0 = s1, *se = s1 + n; 00051 00052 while(s1 < se) 00053 *s1++ = *s2++; 00054 return s0; 00055 } 00056 00057 memset(s, c, n) 00058 register char *s; 00059 register int c; 00060 int n; 00061 { 00062 register char *se = s + n; 00063 00064 while(s < se) 00065 *s++ = c; 00066 }