Commit Diff


commit - 553e1a522a949cd391493f7a52f744db659cea96
commit + 8563e129ee477efc5618710af6360209e7b67038
blob - /dev/null
blob + 9929f01e8cc1fccffb64b4699ec6fdf5ad566446 (mode 644)
--- /dev/null
+++ compat/freezero.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "../compat.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+void
+freezero(void *ptr, size_t len)
+{
+	if (ptr == NULL)
+		return;
+
+	memset(ptr, 0, len);
+	free(ptr);
+}
blob - c033ba4de34e96320a61d6375bf1f16b05b79713
blob + 7ebcbc68c791a92ace5a9a049ae8efc6dfd76248
--- compat.h
+++ compat.h
@@ -60,6 +60,10 @@ void		 warn(int, const char *, ...);
 void		 warnx(int, const char *, ...);
 #endif
 
+#ifndef FREEZERO
+void		 freezero(void *, size_t);
+#endif
+
 #ifndef HAVE_GETDTABLECOUNT
 int		 getdtablecount(void);
 #endif
blob - e3946a958fcb5632a54527b036d70e97e12bc3de
blob + 41c372be48cdc1caa8acfae37af34e3c08c491ff
--- configure.ac
+++ configure.ac
@@ -8,6 +8,7 @@ AC_PROG_YACC
 AC_REPLACE_FUNCS([
 	asprintf	\
 	err		\
+	freezero	\
 	getdtablecount	\
 	getdtablesize	\
 	getprogname	\