mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-18 11:31:00 -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:
@ -141,6 +141,10 @@ struct BinarySink {
|
||||
BinarySink_put_data(BinarySink_UPCAST(bs), val, len)
|
||||
#define put_datapl(bs, pl) \
|
||||
BinarySink_put_datapl(BinarySink_UPCAST(bs), pl)
|
||||
#define put_dataz(bs, val) \
|
||||
BinarySink_put_datapl(BinarySink_UPCAST(bs), ptrlen_from_asciz(val))
|
||||
#define put_datalit(bs, val) \
|
||||
BinarySink_put_datapl(BinarySink_UPCAST(bs), PTRLEN_LITERAL(val))
|
||||
|
||||
/* Emit printf-formatted data, with no terminator. */
|
||||
#define put_fmt(bs, ...) \
|
||||
|
Reference in New Issue
Block a user