[Spice-commits] server/dcc-encoders.c server/dcc-encoders.h
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Jun 15 22:19:52 UTC 2016
server/dcc-encoders.c | 36 ++++++++++++++++++++----------------
server/dcc-encoders.h | 1 -
2 files changed, 20 insertions(+), 17 deletions(-)
New commits:
commit e3419b0e12e59467827c795e6cbc6d32b60abed5
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Jun 10 22:36:27 2016 +0100
Remove message_buf from EncoderData
This buffer was just written and then used, no reason to store into
a more persistent structure.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index 098a397..e53fd24 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -26,6 +26,8 @@
#define ZLIB_DEFAULT_COMPRESSION_LEVEL 3
+#define ENCODER_MESSAGE_SIZE 512
+
#define MAX_GLZ_DRAWABLE_INSTANCES 2
typedef struct GlzDrawableInstanceItem GlzDrawableInstanceItem;
@@ -71,11 +73,12 @@ quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((QuicData *)usr)->data);
va_list ap;
+ char message_buf[ENCODER_MESSAGE_SIZE];
va_start(ap, fmt);
- vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+ vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
va_end(ap);
- spice_critical("%s", usr_data->message_buf);
+ spice_critical("%s", message_buf);
longjmp(usr_data->jmp_env, 1);
}
@@ -85,11 +88,12 @@ lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
{
EncoderData *usr_data = &(((LzData *)usr)->data);
va_list ap;
+ char message_buf[ENCODER_MESSAGE_SIZE];
va_start(ap, fmt);
- vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+ vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
va_end(ap);
- spice_critical("%s", usr_data->message_buf);
+ spice_critical("%s", message_buf);
longjmp(usr_data->jmp_env, 1);
}
@@ -97,14 +101,14 @@ lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
static SPICE_GNUC_PRINTF(2, 3) void
glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, ...)
{
- EncoderData *usr_data = &(((GlzData *)usr)->data);
va_list ap;
+ char message_buf[ENCODER_MESSAGE_SIZE];
va_start(ap, fmt);
- vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+ vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
va_end(ap);
- spice_critical("%s", usr_data->message_buf); // if global lz fails in the middle
+ spice_critical("%s", message_buf); // if global lz fails in the middle
// the consequences are not predictable since the window
// can turn to be unsynchronized between the server and
// and the client
@@ -113,37 +117,37 @@ glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, ...)
static SPICE_GNUC_PRINTF(2, 3) void
quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
{
- EncoderData *usr_data = &(((QuicData *)usr)->data);
va_list ap;
+ char message_buf[ENCODER_MESSAGE_SIZE];
va_start(ap, fmt);
- vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+ vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
va_end(ap);
- spice_warning("%s", usr_data->message_buf);
+ spice_warning("%s", message_buf);
}
static SPICE_GNUC_PRINTF(2, 3) void
lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
{
- EncoderData *usr_data = &(((LzData *)usr)->data);
va_list ap;
+ char message_buf[ENCODER_MESSAGE_SIZE];
va_start(ap, fmt);
- vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+ vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
va_end(ap);
- spice_warning("%s", usr_data->message_buf);
+ spice_warning("%s", message_buf);
}
static SPICE_GNUC_PRINTF(2, 3) void
glz_usr_warn(GlzEncoderUsrContext *usr, const char *fmt, ...)
{
- EncoderData *usr_data = &(((GlzData *)usr)->data);
va_list ap;
+ char message_buf[ENCODER_MESSAGE_SIZE];
va_start(ap, fmt);
- vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+ vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
va_end(ap);
- spice_warning("%s", usr_data->message_buf);
+ spice_warning("%s", message_buf);
}
static void *quic_usr_malloc(QuicUsrContext *usr, int size)
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index e307383..284ed74 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -103,7 +103,6 @@ typedef struct {
int size_left;
} compressed_data; // for encoding data that was already compressed by another method
} u;
- char message_buf[512];
} EncoderData;
typedef struct {
More information about the Spice-commits
mailing list