lib/string/memset/: memzero(), strzero(): Return the pointer

This allows chaining with free(3) on the same line.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-08-12 02:15:18 +02:00
committed by Serge Hallyn
parent 87a5145719
commit dab8de8a72
2 changed files with 10 additions and 11 deletions

View File

@@ -1,15 +1,13 @@
// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#ident "$Id$"
#include <stddef.h>
#include "string/memset/memzero.h"
extern inline void memzero(void *ptr, size_t size);
extern inline void strzero(char *s);
extern inline void *memzero(void *ptr, size_t size);
extern inline char *strzero(char *s);

View File

@@ -1,5 +1,5 @@
// SPDX-FileCopyrightText: 2022-2023, Christian Göttsche <cgzones@googlemail.com>
// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
@@ -19,11 +19,11 @@
#define MEMZERO(arr) memzero(arr, SIZEOF_ARRAY(arr))
inline void memzero(void *ptr, size_t size);
inline void strzero(char *s);
inline void *memzero(void *ptr, size_t size);
inline char *strzero(char *s);
inline void
inline void *
memzero(void *ptr, size_t size)
{
#if defined(HAVE_MEMSET_EXPLICIT)
@@ -34,13 +34,14 @@ memzero(void *ptr, size_t size)
bzero(ptr, size);
__asm__ __volatile__ ("" : : "r"(ptr) : "memory");
#endif
return ptr;
}
inline void
inline char *
strzero(char *s)
{
memzero(s, strlen(s));
return memzero(s, strlen(s));
}