xref: /illumos-gate/usr/src/uts/common/gssapi/mechs/krb5/krb5/os/krb_memset.c (revision a4955f4fa65e38d70c07d38e657a9aff43fa155f)
1 /*
2  * Copyright 2002-2003 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #include <k5-int.h>
7 
8 /*
9  * Note, there is no memset() in kernel land.  This code is a replacement for
10  * use in the kerberos kernel mech.
11  * As a performance enhancement, bzero is called if the fill pattern is 0.
12  */
13 void *
14 krb5_memset(void *sp1, int c, size_t n)
15 {
16 	if (n > 0) {
17 		if (c == 0) {
18 			bzero(sp1, n);
19 		} else {
20 			unsigned char *sp = sp1;
21 			do {
22 				*sp++ = (unsigned char)c;
23 			} while (--n != 0);
24 		}
25 	}
26 
27 	return (sp1);
28 }
29