mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Marshalling macros put_dataz and put_datalit.
When I wanted to append an ordinary C string to a BinarySink, without any prefix length field or suffix terminator, I was using the idiom put_datapl(bs, ptrlen_from_asciz(string)); but I've finally decided that's too cumbersome, and it deserves a shorter name. put_dataz(bs, string) now does the same thing - in fact it's a macro expanding to exactly the above. While I'm at it, I've also added put_datalit(), which is the same except that it expects a C string literal (and will enforce that at compile time, via PTRLEN_LITERAL which it calls in turn). You can use that where possible to avoid the run-time cost of the strlen.
This commit is contained in:
@ -11,7 +11,7 @@ void seat_antispoof_msg(InteractionReadySeat iseat, const char *msg)
|
||||
* generated by the client, then we can just use the message
|
||||
* unmodified as an unspoofable header.
|
||||
*/
|
||||
put_datapl(sb, ptrlen_from_asciz(msg));
|
||||
put_dataz(sb, msg);
|
||||
} else if (*msg) {
|
||||
/*
|
||||
* Otherwise, add enough padding around it that the server
|
||||
|
@ -34,7 +34,7 @@ void add_prompt(prompts_t *p, char *promptstr, bool echo)
|
||||
void prompt_set_result(prompt_t *pr, const char *newstr)
|
||||
{
|
||||
strbuf_clear(pr->result);
|
||||
put_datapl(pr->result, ptrlen_from_asciz(newstr));
|
||||
put_dataz(pr->result, newstr);
|
||||
}
|
||||
|
||||
const char *prompt_get_result_ref(prompt_t *pr)
|
||||
|
Reference in New Issue
Block a user