memzero.h: Add MEMZERO() macro

It calculates the size of the array safely, via SIZEOF_ARRAY(), instead of
sizeof(), which can be dangerous.

Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar 2023-07-30 14:32:39 +02:00 committed by Iker Pedrosa
parent e299942189
commit 64ab401239

View File

@ -15,6 +15,11 @@
#include <string.h>
#include <strings.h>
#include "sizeof.h"
#define MEMZERO(arr) memzero(arr, SIZEOF_ARRAY(arr))
inline void memzero(void *ptr, size_t size);
inline void strzero(char *s);