diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-02 00:27:54 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-02 00:27:54 +0000 |
commit | c941fb14b694de4abf7cb9603e4c139689b2cd92 (patch) | |
tree | c3af4fd05dc8b9044bda48c492c562751ae7891b /utils.c | |
parent | 4186279fc1dbf4471c1666bc0df2e688a45cd229 (diff) |
add experimental ast_copy_string() function to be used in place of strncpy() (see discussion on asterisk-dev)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5547 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rwxr-xr-x | utils.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -418,6 +418,15 @@ int ast_wait_for_input(int fd, int ms) return poll(pfd, 1, ms); } +void ast_copy_string(char *dst, const char *src, size_t size) +{ + while (*src && size--) + *dst++ = *src++; + if (__builtin_expect(!size, 0)) + dst--; + *dst = '\0'; +} + /* Case-insensitive substring matching */ #ifndef LINUX static char *upper(const char *orig, char *buf, int bufsize) |