Helper Reference Manual 1.7.1
Loading...
Searching...
No Matches
string.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2024 Nokia
3 */
4
11#ifndef ODPH_STRING_H_
12#define ODPH_STRING_H_
13
14#include <odp/api/hints.h>
15#include <string.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
42#ifdef __cplusplus
43ODP_UNUSED static char *odph_strcpy(char *dst, const char *src, size_t sz)
44#else
45ODP_UNUSED static char *odph_strcpy(char *restrict dst, const char *restrict src, size_t sz)
46#endif
47{
48 if (!sz)
49 return dst;
50
51#pragma GCC diagnostic push
52#if __GNUC__ >= 8
53#pragma GCC diagnostic ignored "-Wstringop-truncation"
54#endif
55 strncpy(dst, src, sz - 1);
56#pragma GCC diagnostic pop
57 dst[sz - 1] = 0;
58 return dst;
59}
60
65#ifdef __cplusplus
66}
67#endif
68
69#endif
static ODP_UNUSED char * odph_strcpy(char *restrict dst, const char *restrict src, size_t sz)
Copy a string.
Definition string.h:45
ODP string helper.