lib/string/strdup/xstrdup.[ch], lib/, src/: Move xstrdup() to its own file

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-06-27 14:16:16 +02:00
committed by Serge Hallyn
parent 2cf73c99a6
commit 29f4f03def
26 changed files with 81 additions and 32 deletions

View File

@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "string/strdup/xstrdup.h"
extern inline char *xstrdup(const char *str);

View File

@@ -0,0 +1,32 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRDUP_H_
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRDUP_H_
#include <config.h>
#include <string.h>
#include "alloc.h"
#include "attr.h"
ATTR_MALLOC(free)
inline char *xstrdup(const char *str);
inline char *
xstrdup(const char *str)
{
return strcpy(XMALLOC(strlen(str) + 1, char), str);
}
#endif // include guard