12fe8fb19SBen Gras.\" Copyright (c) 1990, 1991, 1993 22fe8fb19SBen Gras.\" The Regents of the University of California. All rights reserved. 32fe8fb19SBen Gras.\" 42fe8fb19SBen Gras.\" This code is derived from software contributed to Berkeley by 52fe8fb19SBen Gras.\" Chris Torek and the American National Standards Committee X3, 62fe8fb19SBen Gras.\" on Information Processing Systems. 72fe8fb19SBen Gras.\" 82fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without 92fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions 102fe8fb19SBen Gras.\" are met: 112fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright 122fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer. 132fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 142fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer in the 152fe8fb19SBen Gras.\" documentation and/or other materials provided with the distribution. 162fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors 172fe8fb19SBen Gras.\" may be used to endorse or promote products derived from this software 182fe8fb19SBen Gras.\" without specific prior written permission. 192fe8fb19SBen Gras.\" 202fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 212fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 222fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 232fe8fb19SBen Gras.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 242fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 252fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 262fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 272fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 282fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 292fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 302fe8fb19SBen Gras.\" SUCH DAMAGE. 312fe8fb19SBen Gras.\" 322fe8fb19SBen Gras.\" from: @(#)memset.3 8.1 (Berkeley) 6/4/93 33*84d9c625SLionel Sambuc.\" $NetBSD: memset.3,v 1.12 2013/06/24 07:56:49 wiz Exp $ 342fe8fb19SBen Gras.\" 35*84d9c625SLionel Sambuc.Dd June 23, 2013 362fe8fb19SBen Gras.Dt MEMSET 3 372fe8fb19SBen Gras.Os 382fe8fb19SBen Gras.Sh NAME 392fe8fb19SBen Gras.Nm memset 402fe8fb19SBen Gras.Nd write a byte to byte string 412fe8fb19SBen Gras.Sh LIBRARY 422fe8fb19SBen Gras.Lb libc 432fe8fb19SBen Gras.Sh SYNOPSIS 442fe8fb19SBen Gras.In string.h 452fe8fb19SBen Gras.Ft void * 462fe8fb19SBen Gras.Fn memset "void *b" "int c" "size_t len" 472fe8fb19SBen Gras.Sh DESCRIPTION 482fe8fb19SBen GrasThe 492fe8fb19SBen Gras.Fn memset 502fe8fb19SBen Grasfunction 512fe8fb19SBen Graswrites 522fe8fb19SBen Gras.Fa len 532fe8fb19SBen Grasbytes of value 542fe8fb19SBen Gras.Fa c 552fe8fb19SBen Gras(converted to an unsigned char) to the string 562fe8fb19SBen Gras.Fa b . 572fe8fb19SBen Gras.Sh RETURN VALUES 582fe8fb19SBen GrasThe 592fe8fb19SBen Gras.Fn memset 602fe8fb19SBen Grasfunction 612fe8fb19SBen Grasreturns the original value of 622fe8fb19SBen Gras.Fa b . 63*84d9c625SLionel Sambuc.Pp 64*84d9c625SLionel SambucNote that the compiler may optimize away a call to 65*84d9c625SLionel Sambuc.Fn memset 66*84d9c625SLionel Sambucif it can prove that the string will not be used by the program again, 67*84d9c625SLionel Sambucfor example if it is allocated on the stack and about to out of scope. 68*84d9c625SLionel SambucIf you want to guarantee that zeros are written to memory, for example 69*84d9c625SLionel Sambucto sanitize a buffer holding a cryptographic secret, use 70*84d9c625SLionel Sambuc.Xr explicit_memset 3 . 712fe8fb19SBen Gras.Sh SEE ALSO 722fe8fb19SBen Gras.Xr bzero 3 , 73*84d9c625SLionel Sambuc.Xr explicit_memset 3 , 742fe8fb19SBen Gras.Xr swab 3 752fe8fb19SBen Gras.Sh STANDARDS 762fe8fb19SBen GrasThe 772fe8fb19SBen Gras.Fn memset 782fe8fb19SBen Grasfunction 792fe8fb19SBen Grasconforms to 802fe8fb19SBen Gras.St -ansiC . 81