mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
bufchain: new combined fetch + consume functions.
bufchain_fetch_consume is a one-stop function that moves a given number of bytes out of the head of a bufchain into an output buffer, removing them from the bufchain in the process. That function will fail an assertion (just like bufchain_fetch) if the bufchain doesn't actually _have_ at least that many bytes to read, so I also provide bufchain_try_fetch_consume which will return a success or failure status. Nothing uses these functions yet, but they will.
This commit is contained in:
parent
e3bdd6231e
commit
9d96c3eb02
16
misc.c
16
misc.c
@ -751,6 +751,22 @@ void bufchain_fetch(bufchain *ch, void *data, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bufchain_fetch_consume(bufchain *ch, void *data, int len)
|
||||||
|
{
|
||||||
|
bufchain_fetch(ch, data, len);
|
||||||
|
bufchain_consume(ch, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bufchain_try_fetch_consume(bufchain *ch, void *data, int len)
|
||||||
|
{
|
||||||
|
if (ch->buffersize >= len) {
|
||||||
|
bufchain_fetch_consume(ch, data, len);
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* My own versions of malloc, realloc and free. Because I want
|
* My own versions of malloc, realloc and free. Because I want
|
||||||
* malloc and realloc to bomb out and exit the program if they run
|
* malloc and realloc to bomb out and exit the program if they run
|
||||||
|
2
misc.h
2
misc.h
@ -82,6 +82,8 @@ void bufchain_add(bufchain *ch, const void *data, int len);
|
|||||||
void bufchain_prefix(bufchain *ch, void **data, int *len);
|
void bufchain_prefix(bufchain *ch, void **data, int *len);
|
||||||
void bufchain_consume(bufchain *ch, int len);
|
void bufchain_consume(bufchain *ch, int len);
|
||||||
void bufchain_fetch(bufchain *ch, void *data, int len);
|
void bufchain_fetch(bufchain *ch, void *data, int len);
|
||||||
|
void bufchain_fetch_consume(bufchain *ch, void *data, int len);
|
||||||
|
int bufchain_try_fetch_consume(bufchain *ch, void *data, int len);
|
||||||
|
|
||||||
int validate_manual_hostkey(char *key);
|
int validate_manual_hostkey(char *key);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user