xref: /openbsd-src/sys/lib/libsa/memset.c (revision 599546b3df9d501c5df00d16afc0d6ef8054a751)
1*599546b3Sderaadt /*	$OpenBSD: memset.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $	*/
21b893c82Smickey 
31b893c82Smickey /*-
41b893c82Smickey  * Copyright (c) 1993
51b893c82Smickey  *	The Regents of the University of California.  All rights reserved.
61b893c82Smickey  *
71b893c82Smickey  * Redistribution and use in source and binary forms, with or without
81b893c82Smickey  * modification, are permitted provided that the following conditions
91b893c82Smickey  * are met:
101b893c82Smickey  * 1. Redistributions of source code must retain the above copyright
111b893c82Smickey  *    notice, this list of conditions and the following disclaimer.
121b893c82Smickey  * 2. Redistributions in binary form must reproduce the above copyright
131b893c82Smickey  *    notice, this list of conditions and the following disclaimer in the
141b893c82Smickey  *    documentation and/or other materials provided with the distribution.
1529295d1cSmillert  * 3. Neither the name of the University nor the names of its contributors
161b893c82Smickey  *    may be used to endorse or promote products derived from this software
171b893c82Smickey  *    without specific prior written permission.
181b893c82Smickey  *
191b893c82Smickey  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
201b893c82Smickey  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
211b893c82Smickey  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
221b893c82Smickey  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
231b893c82Smickey  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
241b893c82Smickey  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
251b893c82Smickey  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
261b893c82Smickey  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
271b893c82Smickey  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
281b893c82Smickey  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291b893c82Smickey  * SUCH DAMAGE.
301b893c82Smickey  *
311b893c82Smickey  *	from: @(#)bcopy.c	8.1 (Berkeley) 6/11/93
321b893c82Smickey  */
331b893c82Smickey 
341b893c82Smickey #include <sys/types.h>
351b893c82Smickey #include "stand.h"
361b893c82Smickey 
371b893c82Smickey void *
memset(void * s1,int c,size_t n)3853c346fbSderaadt memset(void *s1, int c, size_t n)
391b893c82Smickey {
40*599546b3Sderaadt 	char *p = s1;
41*599546b3Sderaadt 
421b893c82Smickey 	while (n--)
431b893c82Smickey 		*p++ = c;
441b893c82Smickey 	return s1;
451b893c82Smickey }
46