xref: /netbsd-src/external/bsd/libfido2/dist/openbsd-compat/freezero.c (revision 95dbdf3206203c8af99d6fed1ad2822e093852fa)
1*95dbdf32Schristos /*
2*95dbdf32Schristos  * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
3*95dbdf32Schristos  *
4*95dbdf32Schristos  * Permission to use, copy, modify, and distribute this software for any
5*95dbdf32Schristos  * purpose with or without fee is hereby granted, provided that the above
6*95dbdf32Schristos  * copyright notice and this permission notice appear in all copies.
7*95dbdf32Schristos  *
8*95dbdf32Schristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*95dbdf32Schristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*95dbdf32Schristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*95dbdf32Schristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*95dbdf32Schristos  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*95dbdf32Schristos  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*95dbdf32Schristos  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*95dbdf32Schristos  */
16*95dbdf32Schristos 
17*95dbdf32Schristos #include "openbsd-compat.h"
18*95dbdf32Schristos 
19*95dbdf32Schristos #ifndef HAVE_FREEZERO
20*95dbdf32Schristos 
21*95dbdf32Schristos void
freezero(void * ptr,size_t sz)22*95dbdf32Schristos freezero(void *ptr, size_t sz)
23*95dbdf32Schristos {
24*95dbdf32Schristos 	if (ptr == NULL)
25*95dbdf32Schristos 		return;
26*95dbdf32Schristos 	explicit_bzero(ptr, sz);
27*95dbdf32Schristos 	free(ptr);
28*95dbdf32Schristos }
29*95dbdf32Schristos 
30*95dbdf32Schristos #endif /* HAVE_FREEZERO */
31