diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2005-05-02 00:27:54 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2005-05-02 00:27:54 +0000 |
commit | abec217a1bcf62a6d19c5f040d092ac501095221 (patch) | |
tree | c3af4fd05dc8b9044bda48c492c562751ae7891b /utils.c | |
parent | 405000c8978ef0694be375fd592d809612c6ee1d (diff) |
add experimental ast_copy_string() function to be used in place of strncpy() (see discussion on asterisk-dev)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5547 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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) |