mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-24 11:49:48 +00:00
simplify pstrcpy()
Originally committed as revision 9391 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
12a6f28928
commit
26301cb806
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user