xref: /netbsd-src/external/bsd/tmux/dist/compat/freezero.c (revision 4e179ddab96f97aa64efc589ce1918be5318aaaf)
1*4e179ddaSchristos /*
2*4e179ddaSchristos  * Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
3*4e179ddaSchristos  *
4*4e179ddaSchristos  * Permission to use, copy, modify, and distribute this software for any
5*4e179ddaSchristos  * purpose with or without fee is hereby granted, provided that the above
6*4e179ddaSchristos  * copyright notice and this permission notice appear in all copies.
7*4e179ddaSchristos  *
8*4e179ddaSchristos  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*4e179ddaSchristos  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*4e179ddaSchristos  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*4e179ddaSchristos  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*4e179ddaSchristos  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13*4e179ddaSchristos  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14*4e179ddaSchristos  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*4e179ddaSchristos  */
16*4e179ddaSchristos 
17*4e179ddaSchristos #include <sys/types.h>
18*4e179ddaSchristos 
19*4e179ddaSchristos #include <stdlib.h>
20*4e179ddaSchristos #include <string.h>
21*4e179ddaSchristos 
22*4e179ddaSchristos #include "compat.h"
23*4e179ddaSchristos 
24*4e179ddaSchristos void
freezero(void * ptr,size_t size)25*4e179ddaSchristos freezero(void *ptr, size_t size)
26*4e179ddaSchristos {
27*4e179ddaSchristos 	if (ptr != NULL) {
28*4e179ddaSchristos 		memset(ptr, 0, size);
29*4e179ddaSchristos 		free(ptr);
30*4e179ddaSchristos 	}
31*4e179ddaSchristos }
32