[Spice-devel] [PATCH 4/5] LZ4: Implement htonl to remove dependency on arpa/inte.h
Christophe Fergeau
cfergeau at redhat.com
Mon Jan 26 08:34:20 PST 2015
Same comment as before, you can just use GUINT32_TO_BE
Christophe
On Thu, Jan 22, 2015 at 05:21:07PM +0100, Javier Celaya wrote:
> ---
> server/lz4_encoder.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/server/lz4_encoder.c b/server/lz4_encoder.c
> index 2327e9a..4f0f3c8 100644
> --- a/server/lz4_encoder.c
> +++ b/server/lz4_encoder.c
> @@ -22,7 +22,6 @@
>
> #define SPICE_LOG_DOMAIN "SpiceLz4Encoder"
>
> -#include <arpa/inet.h>
> #include <lz4.h>
> #include "red_common.h"
> #include "lz4_encoder.h"
> @@ -31,6 +30,16 @@ typedef struct Lz4Encoder {
> Lz4EncoderUsrContext *usr;
> } Lz4Encoder;
>
> +static inline void encode32(uint8_t *buffer, uint32_t value)
> +{
> + // Network order -> big endian
> + int i;
> + for (i = 3; i > -1; --i) {
> + buffer[i] = value & 0xFF;
> + value >>= 8;
> + }
> +}
> +
> Lz4EncoderContext* lz4_encoder_create(Lz4EncoderUsrContext *usr)
> {
> Lz4Encoder *enc;
> @@ -85,7 +94,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
> LZ4_freeStream(stream);
> return 0;
> }
> - *((uint32_t *)compressed_lines) = htonl(enc_size);
> + encode32(compressed_lines, enc_size);
>
> out_size += enc_size += 4;
> already_copied = 0;
> --
> 1.9.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150126/fc2b8778/attachment-0001.sig>
More information about the Spice-devel
mailing list