Hey, As this is not going to be built using MSVC, I don't think it's a huge problem using ntohl. If you really don't want to use it, I'd favour adding a dependency on glib, and using GUINT32_FROM_LE. Christophe On Thu, Jan 22, 2015 at 05:21:20PM +0100, Javier Celaya wrote: > --- > common/canvas_base.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/common/canvas_base.c b/common/canvas_base.c > index cfbba5e..0f6b7f4 100644 > --- a/common/canvas_base.c > +++ b/common/canvas_base.c > @@ -27,7 +27,6 @@ > #include <math.h> > > #ifdef USE_LZ4 > -#include <arpa/inet.h> > #include <lz4.h> > #endif > #include <spice/macros.h> > @@ -548,6 +547,18 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase *canvas, SpiceImage *image, in > } > > #ifdef USE_LZ4 > +static inline uint32_t lz4_decode32(uint8_t *buffer) > +{ > + // Network order -> big endian > + uint32_t value = 0; > + int i; > + for (i = 0; i < 4; ++i) { > + value <<= 8; > + value += buffer[i]; > + } > + return value; > +} > + > static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int invers) > { > pixman_image_t *surface = NULL; > @@ -587,7 +598,7 @@ static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage *image, int > > do { > // Read next compressed block > - enc_size = ntohl(*((uint32_t *)data)); > + enc_size = lz4_decode32(data); > data += 4; > dec_size = LZ4_decompress_safe_continue(stream, (const char *) data, > (char *) dest, enc_size, available); > -- > 1.9.3 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/spice-devel
Attachment:
pgpe7j2gRJ868.pgp
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel