1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-15 10:07:39 -05:00

New utility functions to make ptrlens.

One to make one from a NUL-terminated string, and another to make one
from a strbuf. I've switched over all the obvious cases where I should
have been using these functions.
This commit is contained in:
Simon Tatham
2018-10-13 16:30:59 +01:00
parent b9bfc81531
commit 56096ba558
5 changed files with 18 additions and 6 deletions

10
misc.c
View File

@ -1243,6 +1243,16 @@ ptrlen make_ptrlen(const void *ptr, size_t len)
return pl;
}
ptrlen ptrlen_from_asciz(const char *str)
{
return make_ptrlen(str, strlen(str));
}
ptrlen ptrlen_from_strbuf(strbuf *sb)
{
return make_ptrlen(sb->u, sb->len);
}
int ptrlen_eq_string(ptrlen pl, const char *str)
{
size_t len = strlen(str);