make puff const correct instead of const-casting

This commit is contained in:
Arvid Norberg 2015-04-22 02:11:12 +00:00
parent 3664c7c137
commit a1f59f6cf1
3 changed files with 4 additions and 5 deletions

View File

@ -29,5 +29,5 @@
int puff(unsigned char *dest, /* pointer to destination pointer */ int puff(unsigned char *dest, /* pointer to destination pointer */
boost::uint32_t *destlen, /* amount of output space */ 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 */ boost::uint32_t *sourcelen); /* amount of input available */

View File

@ -220,8 +220,7 @@ namespace libtorrent
} }
ret = puff(reinterpret_cast<unsigned char*>(&buffer[0]), &destlen ret = puff(reinterpret_cast<unsigned char*>(&buffer[0]), &destlen
, const_cast<unsigned char*>( , reinterpret_cast<const unsigned char*>(in), &srclen);
reinterpret_cast<const unsigned char*>(in)), &srclen);
// if the destination buffer wasn't large enough, double its // if the destination buffer wasn't large enough, double its
// size and try again. Unless it's already at its max, in which // size and try again. Unless it's already at its max, in which

View File

@ -99,7 +99,7 @@ struct state {
boost::uint32_t outcnt; /* bytes written to out so far */ boost::uint32_t outcnt; /* bytes written to out so far */
/* input state */ /* input state */
unsigned char *in; /* input buffer */ const unsigned char *in; /* input buffer */
boost::uint32_t inlen; /* available input at in */ boost::uint32_t inlen; /* available input at in */
boost::uint32_t incnt; /* bytes read so far */ boost::uint32_t incnt; /* bytes read so far */
int bitbuf; /* bit buffer */ int bitbuf; /* bit buffer */
@ -748,7 +748,7 @@ local int dynamic(struct state *s)
*/ */
int puff(unsigned char *dest, /* pointer to destination pointer */ int puff(unsigned char *dest, /* pointer to destination pointer */
boost::uint32_t *destlen, /* amount of output space */ 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 */ boost::uint32_t *sourcelen) /* amount of input available */
{ {
struct state s; /* input/output state */ struct state s; /* input/output state */