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:
11
marshal.c
11
marshal.c
@ -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);
|
||||
|
Reference in New Issue
Block a user