[Spice-devel] [PATCH 09/17] Add RedsStream::priv
Christophe Fergeau
cfergeau at redhat.com
Tue Jan 7 03:14:35 PST 2014
The private data is allocated at the same time as RedsStream and
goes immediatly after the main RedsStream data.
This private member will allow to hide internal RedsStream
implementation details from the rest of spice-server.
---
server/reds_stream.c | 6 +++++-
server/reds_stream.h | 4 ++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/server/reds_stream.c b/server/reds_stream.c
index 2703ec7..e94995c 100644
--- a/server/reds_stream.c
+++ b/server/reds_stream.c
@@ -33,6 +33,9 @@
extern SpiceCoreInterface *core;
+struct RedsStreamPrivate {
+};
+
static ssize_t stream_write_cb(RedsStream *s, const void *buf, size_t size)
{
return write(s->socket, buf, size);
@@ -238,7 +241,8 @@ RedsStream *reds_stream_new(int socket)
{
RedsStream *stream;
- stream = spice_new0(RedsStream, 1);
+ stream = spice_malloc0(sizeof(RedsStream) + sizeof(RedsStreamPrivate));
+ stream->priv = (RedsStreamPrivate *)(((char *)stream) + sizeof(RedsStream));
stream->info = spice_new0(SpiceChannelEventInfo, 1);
reds_stream_set_socket(stream, socket);
diff --git a/server/reds_stream.h b/server/reds_stream.h
index cae244b..4927336 100644
--- a/server/reds_stream.h
+++ b/server/reds_stream.h
@@ -74,6 +74,8 @@ void async_read_set_error_handler(AsyncRead *async,
AsyncReadError error_handler,
void *opaque);
+typedef struct RedsStreamPrivate RedsStreamPrivate;
+
struct RedsStream {
int socket;
SpiceWatch *watch;
@@ -99,6 +101,8 @@ struct RedsStream {
ssize_t (*read)(RedsStream *s, void *buf, size_t nbyte);
ssize_t (*write)(RedsStream *s, const void *buf, size_t nbyte);
ssize_t (*writev)(RedsStream *s, const struct iovec *iov, int iovcnt);
+
+ RedsStreamPrivate *priv;
};
typedef enum {
--
1.8.4.2
More information about the Spice-devel
mailing list