/[inetutils]/inetutils/libinetutils/memset.c
ViewVC logotype

Diff of /inetutils/libinetutils/memset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by miles, Mon Jan 6 23:43:50 1997 UTC revision 1.2 by jbailey, Wed Dec 11 13:19:52 2002 UTC
# Line 1  Line 1 
1  /* Stupid ass version of memset  /* memset.c -- set an area of memory to a given value
2       Copyright (C) 1991 Free Software Foundation, Inc.
3    
4     Copyright (C) 1996, 1997 Free Software Foundation, Inc.     This program is free software; you can redistribute it and/or modify
5       it under the terms of the GNU General Public License as published by
6     Written by Miles Bader <miles@gnu.ai.mit.edu>     the Free Software Foundation; either version 2, or (at your option)
7       any later version.
8     This program is free software; you can redistribute it and/or  
9     modify it under the terms of the GNU General Public License as     This program is distributed in the hope that it will be useful,
10     published by the Free Software Foundation; either version 2, or (at     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     your option) any later version.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12       GNU General Public License for more details.
    This program is distributed in the hope that it will be useful, but  
    WITHOUT ANY WARRANTY; without even the implied warranty of  
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  
    General Public License for more details.  
13    
14     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software Foundation,
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
17    
18  #ifdef HAVE_CONFIG_H  char *
19  #include <config.h>  memset (char *str, int c, unsigned int len)
 #endif  
   
 #ifdef HAVE_STDLIB_H  
 #include <stdlib.h>  
 #endif  
 #ifdef HAVE_STRING_H  
 #include <string.h>  
 #endif  
   
 void  
 memset (mem, val, sz)  
      void *mem;  
      int val;  
      size_t sz;  
20  {  {
21  #ifdef HAVE_BZERO    register char *st = str;
22    if (val == 0)  
23      bzero (mem, sz);    while (len-- > 0)
24    else      *st++ = c;
25  #endif    return str;
     /* Not *too* efficient... */  
     {  
       char *p = mem;  
       while (sz-- > 0)  
         *p++ = val;  
     }  
26  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26