Added Stream_ConstBuffer function

This commit is contained in:
Armin Novak 2022-02-01 10:50:53 +01:00 committed by akallabeth
parent 1f59dff316
commit a40467b3b0
2 changed files with 8 additions and 2 deletions

View File

@ -1476,11 +1476,11 @@ fail:
static void* stream_copy(const void* obj) static void* stream_copy(const void* obj)
{ {
wStream* src = obj; const wStream* src = obj;
wStream* dst = Stream_New(NULL, Stream_Capacity(src)); wStream* dst = Stream_New(NULL, Stream_Capacity(src));
if (!dst) if (!dst)
return NULL; return NULL;
memcpy(Stream_Buffer(dst), Stream_Buffer(src), Stream_Capacity(dst)); memcpy(Stream_Buffer(dst), Stream_ConstBuffer(src), Stream_Capacity(dst));
Stream_SetLength(dst, Stream_Length(src)); Stream_SetLength(dst, Stream_Length(src));
Stream_SetPosition(dst, Stream_GetPosition(src)); Stream_SetPosition(dst, Stream_GetPosition(src));
return dst; return dst;

View File

@ -353,6 +353,12 @@ extern "C"
return _s->buffer; return _s->buffer;
} }
static INLINE const BYTE* Stream_ConstBuffer(const wStream* _s)
{
WINPR_ASSERT(_s);
return _s->buffer;
}
#define Stream_GetBuffer(_s, _b) _b = Stream_Buffer(_s) #define Stream_GetBuffer(_s, _b) _b = Stream_Buffer(_s)
static INLINE BYTE* Stream_Pointer(wStream* _s) static INLINE BYTE* Stream_Pointer(wStream* _s)