...
Code Block | ||||
---|---|---|---|---|
| ||||
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
enum { STR_SIZE = 32 };
size_t func(const char *source) {
char c_str[STR_SIZE];
size_t ret = 0;
if (source) {
errno_t err = strncpy_s(
c_str, sizeof(c_str), source, strnlen(source, sizeof(c_str))
);
if (err != 0) {
/* Handle error */
} else {
ret = strnlen_s(c_str, sizeof(c_str));
}
} else {
/* Handle null pointer */
}
return ret;
}
|
...