1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-17 19:11:00 -05:00

New BinarySink function 'put_padding'.

It is to put_data what memset is to memcpy. Several places
in the code wanted it already, but not _quite_ enough for me to
have written it with the rest of the BinarySink infrastructure
originally.
This commit is contained in:
Simon Tatham
2018-06-09 09:01:07 +01:00
parent 72c2b70736
commit 8b98fea4ae
5 changed files with 19 additions and 6 deletions

View File

@ -11,6 +11,17 @@ void BinarySink_put_data(BinarySink *bs, const void *data, size_t len)
bs->write(bs, data, len);
}
void BinarySink_put_padding(BinarySink *bs, unsigned char padbyte, size_t len)
{
char buf[16];
memset(buf, padbyte, sizeof(buf));
while (len > 0) {
size_t thislen = len < sizeof(buf) ? len : sizeof(buf);
bs->write(bs, buf, thislen);
len -= thislen;
}
}
void BinarySink_put_byte(BinarySink *bs, unsigned char val)
{
bs->write(bs, &val, 1);