mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 06:39:39 +00:00
add xargvlen
This commit is contained in:
parent
7343b233e4
commit
e9468b25e1
2 changed files with 16 additions and 0 deletions
|
@ -10,6 +10,18 @@
|
||||||
# include <tchar.h>
|
# include <tchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
size_t
|
||||||
|
xargvlen(const char *const *argv, size_t *n_args) {
|
||||||
|
size_t i, len = 0;
|
||||||
|
for (i = 0; argv[i]; i++) {
|
||||||
|
len += strlen(argv[i]);
|
||||||
|
if(i != 0) len += 1; /* extra for space */
|
||||||
|
}
|
||||||
|
if (n_args) *n_args = i;
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
xstrncpy(char *dest, const char *src, size_t n) {
|
xstrncpy(char *dest, const char *src, size_t n) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
// returns the flat buffer size large enough to store all argv elements (excluding nul terminator) plus separating spaces
|
||||||
|
size_t
|
||||||
|
xargvlen(const char * const argv[], size_t *n_args);
|
||||||
|
|
||||||
// like strncpy, except:
|
// like strncpy, except:
|
||||||
// - it copies at most n-1 chars
|
// - it copies at most n-1 chars
|
||||||
// - the dest string is nul-terminated
|
// - the dest string is nul-terminated
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue