SDDSlib
Loading...
Searching...
No Matches
SDDS
mdblib
str_copy.c
Go to the documentation of this file.
1
/**
2
* @file str_copy.c
3
* @brief Implementation of the strcpy_ss function for safe string copying.
4
*
5
* This file contains the implementation of the strcpy_ss function, which safely
6
* copies a string from the source to the destination buffer, ensuring that overlapping
7
* memory regions are handled correctly.
8
*
9
* @copyright
10
* - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
11
* - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
12
*
13
* @license
14
* This file is distributed under the terms of the Software License Agreement
15
* found in the file LICENSE included with this distribution.
16
*
17
* @author Y. Wang, M. Borland, R. Soliday
18
*/
19
20
#include <string.h>
21
#include "mdb.h"
22
23
/**
24
* @brief Safely copies a string, handling memory overlap.
25
*
26
* Copies the string pointed to by `src`, including the terminating null byte,
27
* to the buffer pointed to by `dest`. This function ensures that the copy is
28
* performed safely even if the source and destination buffers overlap.
29
*
30
* @param dest Pointer to the destination buffer where the string will be copied.
31
* @param src Pointer to the null-terminated source string to copy.
32
* @return Pointer to the destination string `dest`.
33
*/
34
char
*
strcpy_ss
(
char
*dest,
const
char
*src) {
35
return
(
char
*)memmove(dest, src, strlen(src) + 1);
36
}
strcpy_ss
char * strcpy_ss(char *dest, const char *src)
Safely copies a string, handling memory overlap.
Definition
str_copy.c:34
Generated by
1.12.0