From a1f59f6cf197e08e6c2b658762996f944d5f2ca8 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 22 Apr 2015 02:11:12 +0000 Subject: [PATCH] make puff const correct instead of const-casting --- include/libtorrent/puff.hpp | 2 +- src/gzip.cpp | 3 +-- src/puff.cpp | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/libtorrent/puff.hpp b/include/libtorrent/puff.hpp index 5af5abb0c..7b2c4eab8 100644 --- a/include/libtorrent/puff.hpp +++ b/include/libtorrent/puff.hpp @@ -29,5 +29,5 @@ int puff(unsigned char *dest, /* pointer to destination pointer */ boost::uint32_t *destlen, /* amount of output space */ - unsigned char *source, /* pointer to source data pointer */ + const unsigned char *source, /* pointer to source data pointer */ boost::uint32_t *sourcelen); /* amount of input available */ diff --git a/src/gzip.cpp b/src/gzip.cpp index c19f62681..0079b237e 100644 --- a/src/gzip.cpp +++ b/src/gzip.cpp @@ -220,8 +220,7 @@ namespace libtorrent } ret = puff(reinterpret_cast(&buffer[0]), &destlen - , const_cast( - reinterpret_cast(in)), &srclen); + , reinterpret_cast(in), &srclen); // if the destination buffer wasn't large enough, double its // size and try again. Unless it's already at its max, in which diff --git a/src/puff.cpp b/src/puff.cpp index 8074fef38..dcaef91bb 100644 --- a/src/puff.cpp +++ b/src/puff.cpp @@ -99,7 +99,7 @@ struct state { boost::uint32_t outcnt; /* bytes written to out so far */ /* input state */ - unsigned char *in; /* input buffer */ + const unsigned char *in; /* input buffer */ boost::uint32_t inlen; /* available input at in */ boost::uint32_t incnt; /* bytes read so far */ int bitbuf; /* bit buffer */ @@ -748,7 +748,7 @@ local int dynamic(struct state *s) */ int puff(unsigned char *dest, /* pointer to destination pointer */ boost::uint32_t *destlen, /* amount of output space */ - unsigned char *source, /* pointer to source data pointer */ + const unsigned char *source, /* pointer to source data pointer */ boost::uint32_t *sourcelen) /* amount of input available */ { struct state s; /* input/output state */