[winpr,stream] Add Stream_ResetPosition

A helper function that does not require return checks, in contrast to
Stream_SetPosition, which might fail.
This commit is contained in:
Armin Novak
2026-02-27 20:04:43 +01:00
parent 41c9286c3c
commit 92ab55c5e1
65 changed files with 175 additions and 171 deletions

View File

@@ -1319,6 +1319,20 @@ extern "C"
return WINPR_STREAM_CAST(size_t, (_s->pointer - _s->buffer));
}
/** @brief helper to reset stream read/write position to beginning of stream.
*
* Same as \ref Stream_SetPosition(s, 0) but does not need bounds checks.
*
* @param _s A stream to reset the position on. Must not be \b nullptr
*
* @since version 3.24.0
*/
static inline void Stream_ResetPosition(wStream* _s)
{
WINPR_ASSERT(_s);
_s->pointer = _s->buffer;
}
WINPR_API BOOL Stream_SetPosition(wStream* _s, size_t _p);
WINPR_API void Stream_SealLength(wStream* _s);