mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[lzma] signdness
This commit is contained in:
parent
1e4014b2c0
commit
7e1adcc0bb
@ -60,7 +60,7 @@ lzma_open(struct stream_encoded *stream, int fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
lzma_read(struct stream_encoded *stream, unsigned char *buf, int len)
|
lzma_read(struct stream_encoded *stream, char *buf, int len)
|
||||||
{
|
{
|
||||||
struct lzma_enc_data *data = (struct lzma_enc_data *) stream->data;
|
struct lzma_enc_data *data = (struct lzma_enc_data *) stream->data;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -72,7 +72,7 @@ lzma_read(struct stream_encoded *stream, unsigned char *buf, int len)
|
|||||||
if (data->last_read) return 0;
|
if (data->last_read) return 0;
|
||||||
|
|
||||||
data->flzma_stream.avail_out = len;
|
data->flzma_stream.avail_out = len;
|
||||||
data->flzma_stream.next_out = buf;
|
data->flzma_stream.next_out = (unsigned char *)buf;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (data->flzma_stream.avail_in == 0) {
|
if (data->flzma_stream.avail_in == 0) {
|
||||||
@ -102,21 +102,21 @@ lzma_read(struct stream_encoded *stream, unsigned char *buf, int len)
|
|||||||
}
|
}
|
||||||
} while (data->flzma_stream.avail_out > 0);
|
} while (data->flzma_stream.avail_out > 0);
|
||||||
|
|
||||||
assert(len - data->flzma_stream.avail_out == data->flzma_stream.next_out - buf);
|
assert(len - data->flzma_stream.avail_out == data->flzma_stream.next_out - (unsigned char *)buf);
|
||||||
return len - data->flzma_stream.avail_out;
|
return len - data->flzma_stream.avail_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
lzma_decode_buffer(struct stream_encoded *st, unsigned char *data, int len, int *new_len)
|
lzma_decode_buffer(struct stream_encoded *st, char *data, int len, int *new_len)
|
||||||
{
|
{
|
||||||
struct lzma_enc_data *enc_data = (struct lzma_enc_data *) st->data;
|
struct lzma_enc_data *enc_data = (struct lzma_enc_data *) st->data;
|
||||||
lzma_stream *stream = &enc_data->flzma_stream;
|
lzma_stream *stream = &enc_data->flzma_stream;
|
||||||
char *buffer = NULL;
|
unsigned char *buffer = NULL;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
*new_len = 0; /* default, left there if an error occurs */
|
*new_len = 0; /* default, left there if an error occurs */
|
||||||
|
|
||||||
stream->next_in = data;
|
stream->next_in = (unsigned char *)data;
|
||||||
stream->avail_in = len;
|
stream->avail_in = len;
|
||||||
stream->total_out = 0;
|
stream->total_out = 0;
|
||||||
|
|
||||||
@ -124,10 +124,10 @@ lzma_decode_buffer(struct stream_encoded *st, unsigned char *data, int len, int
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char *new_buffer;
|
unsigned char *new_buffer;
|
||||||
size_t size = stream->total_out + MAX_STR_LEN;
|
size_t size = stream->total_out + MAX_STR_LEN;
|
||||||
|
|
||||||
new_buffer = (char *)mem_realloc(buffer, size);
|
new_buffer = (unsigned char *)mem_realloc(buffer, size);
|
||||||
if (!new_buffer) {
|
if (!new_buffer) {
|
||||||
error = LZMA_MEM_ERROR;
|
error = LZMA_MEM_ERROR;
|
||||||
break;
|
break;
|
||||||
@ -152,7 +152,7 @@ lzma_decode_buffer(struct stream_encoded *st, unsigned char *data, int len, int
|
|||||||
|
|
||||||
if (error == LZMA_OK) {
|
if (error == LZMA_OK) {
|
||||||
*new_len = stream->total_out;
|
*new_len = stream->total_out;
|
||||||
return buffer;
|
return (char *)buffer;
|
||||||
} else {
|
} else {
|
||||||
mem_free_if(buffer);
|
mem_free_if(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user