mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-02 12:31:09 +00:00
cutils: add strpadcpy()
Backports commit 2a025ae454c361fb03aadf88e8a2f678b80b38e6 from qemu
This commit is contained in:
parent
7d5ef87f8c
commit
542f162b35
|
@ -98,6 +98,7 @@ int qemu_ftruncate64(int, int64_t);
|
||||||
|
|
||||||
/* cutils.c */
|
/* cutils.c */
|
||||||
void pstrcpy(char *buf, int buf_size, const char *str);
|
void pstrcpy(char *buf, int buf_size, const char *str);
|
||||||
|
void strpadcpy(char *buf, int buf_size, const char *str, char pad);
|
||||||
char *pstrcat(char *buf, int buf_size, const char *s);
|
char *pstrcat(char *buf, int buf_size, const char *s);
|
||||||
int strstart(const char *str, const char *val, const char **ptr);
|
int strstart(const char *str, const char *val, const char **ptr);
|
||||||
int qemu_fls(int i);
|
int qemu_fls(int i);
|
||||||
|
|
|
@ -27,6 +27,12 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
void strpadcpy(char *buf, int buf_size, const char *str, char pad)
|
||||||
|
{
|
||||||
|
int len = qemu_strnlen(str, buf_size);
|
||||||
|
memcpy(buf, str, len);
|
||||||
|
memset(buf + len, pad, buf_size - len);
|
||||||
|
}
|
||||||
|
|
||||||
void pstrcpy(char *buf, int buf_size, const char *str)
|
void pstrcpy(char *buf, int buf_size, const char *str)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue