GUACAMOLE-25: Implement buffer attachment in Stream_New() and Stream_Free() compatibility functions.
This commit is contained in:
parent
1393358469
commit
f1d4393eb8
@ -22,17 +22,26 @@
|
|||||||
#include "winpr-stream.h"
|
#include "winpr-stream.h"
|
||||||
#include "winpr-wtypes.h"
|
#include "winpr-wtypes.h"
|
||||||
|
|
||||||
/*
|
|
||||||
* NOTE: Because the old API did not support local allocation of the buffer
|
|
||||||
* for each stream, these compatibility implementations ignore
|
|
||||||
* the parameters of Stream_New() and Stream_Free() that provide them.
|
|
||||||
*/
|
|
||||||
|
|
||||||
wStream* Stream_New(BYTE* buffer, size_t size) {
|
wStream* Stream_New(BYTE* buffer, size_t size) {
|
||||||
|
|
||||||
|
/* If no buffer is provided, allocate a new stream of the given size */
|
||||||
|
if (buffer == NULL)
|
||||||
return stream_new(size);
|
return stream_new(size);
|
||||||
|
|
||||||
|
/* Otherwise allocate an empty stream and assign the given buffer */
|
||||||
|
wStream* stream = stream_new(0);
|
||||||
|
stream_attach(stream, buffer, size);
|
||||||
|
return stream;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream_Free(wStream* s, BOOL bFreeBuffer) {
|
void Stream_Free(wStream* s, BOOL bFreeBuffer) {
|
||||||
|
|
||||||
|
/* Disassociate buffer if it will be freed externally */
|
||||||
|
if (!bFreeBuffer)
|
||||||
|
stream_detach(s);
|
||||||
|
|
||||||
stream_free(s);
|
stream_free(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user