diff options
author | Måns Rullgård <mans@mansr.com> | 2007-06-23 00:21:06 +0000 |
---|---|---|
committer | Måns Rullgård <mans@mansr.com> | 2007-06-23 00:21:06 +0000 |
commit | 26301cb80611652efbdbf80b77f9de73b488421d (patch) | |
tree | db5a6b5db50af9e9cca8bfee541d5e943560f6cd /libavformat/cutils.c | |
parent | 12a6f28928b85d366478b45422495bf0066fcf05 (diff) | |
download | ffmpeg-26301cb80611652efbdbf80b77f9de73b488421d.tar.gz |
simplify pstrcpy()
Originally committed as revision 9391 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/cutils.c')
-rw-r--r-- | libavformat/cutils.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/libavformat/cutils.c b/libavformat/cutils.c index bde1c1d39a..55257a5a01 100644 --- a/libavformat/cutils.c +++ b/libavformat/cutils.c @@ -75,19 +75,12 @@ int stristart(const char *str, const char *val, const char **ptr) */ void pstrcpy(char *buf, int buf_size, const char *str) { - int c; - char *q = buf; - if (buf_size <= 0) return; - for(;;) { - c = *str++; - if (c == 0 || q >= buf + buf_size - 1) - break; - *q++ = c; - } - *q = '\0'; + while (buf_size-- > 1 && *str) + *buf++ = *str++; + *buf = 0; } /* strcat and truncate. */ |