mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 07:43:52 +00:00
(libchdr) Cleanups + attempts to rebase against upstream
This commit is contained in:
parent
d50c49c4e8
commit
88804a05de
@ -335,7 +335,8 @@ enum huffman_error huffman_compute_tree_from_histo(struct huffman_decoder* decod
|
|||||||
|
|
||||||
/* binary search to achieve the optimum encoding */
|
/* binary search to achieve the optimum encoding */
|
||||||
upperweight = sdatacount * 2;
|
upperweight = sdatacount * 2;
|
||||||
while (1)
|
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
/* build a tree using the current weight */
|
/* build a tree using the current weight */
|
||||||
uint32_t curweight = (upperweight + lowerweight) / 2;
|
uint32_t curweight = (upperweight + lowerweight) / 2;
|
||||||
@ -548,16 +549,13 @@ void huffman_build_lookup_table(struct huffman_decoder* decoder)
|
|||||||
struct node_t* node = &decoder->huffnode[curcode];
|
struct node_t* node = &decoder->huffnode[curcode];
|
||||||
if (node->numbits > 0)
|
if (node->numbits > 0)
|
||||||
{
|
{
|
||||||
int shift;
|
|
||||||
lookup_value *dest;
|
|
||||||
lookup_value *destend;
|
|
||||||
/* set up the entry */
|
/* set up the entry */
|
||||||
lookup_value value = MAKE_LOOKUP(curcode, node->numbits);
|
lookup_value value = MAKE_LOOKUP(curcode, node->numbits);
|
||||||
|
|
||||||
/* fill all matching entries */
|
/* fill all matching entries */
|
||||||
shift = decoder->maxbits - node->numbits;
|
int shift = decoder->maxbits - node->numbits;
|
||||||
dest = &decoder->lookup[node->bits << shift];
|
lookup_value *dest = &decoder->lookup[node->bits << shift];
|
||||||
destend = &decoder->lookup[((node->bits + 1) << shift) - 1];
|
lookup_value *destend = &decoder->lookup[((node->bits + 1) << shift) - 1];
|
||||||
while (dest <= destend)
|
while (dest <= destend)
|
||||||
*dest++ = value;
|
*dest++ = value;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ static void *lzma_fast_alloc(void *p, size_t size)
|
|||||||
|
|
||||||
/* set the low bit of the size so we don't match next time */
|
/* set the low bit of the size so we don't match next time */
|
||||||
*addr = (uint32_t)(size | 1);
|
*addr = (uint32_t)(size | 1);
|
||||||
return addr + 1;
|
return addr + (sizeof(uint32_t) == sizeof(uintptr_t) ? 1 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
|
@ -174,6 +174,10 @@ chd_error zlib_codec_init(void *codec, uint32_t hunkbytes)
|
|||||||
else
|
else
|
||||||
err = CHDERR_NONE;
|
err = CHDERR_NONE;
|
||||||
|
|
||||||
|
/* handle an error */
|
||||||
|
if (err != CHDERR_NONE)
|
||||||
|
free(data);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,7 +277,7 @@ voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
|
|||||||
|
|
||||||
/* set the low bit of the size so we don't match next time */
|
/* set the low bit of the size so we don't match next time */
|
||||||
*ptr = size | 1;
|
*ptr = size | 1;
|
||||||
return ptr + 1;
|
return ptr + (sizeof(uint32_t) == sizeof(uintptr_t) ? 1 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
@ -284,7 +288,7 @@ voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
|
|||||||
void zlib_fast_free(voidpf opaque, voidpf address)
|
void zlib_fast_free(voidpf opaque, voidpf address)
|
||||||
{
|
{
|
||||||
zlib_allocator *alloc = (zlib_allocator *)opaque;
|
zlib_allocator *alloc = (zlib_allocator *)opaque;
|
||||||
UINT32 *ptr = (UINT32 *)address - 1;
|
UINT32 *ptr = (UINT32 *)address - (sizeof(uint32_t) == sizeof(uintptr_t) ? 1 : 2);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* find the hunk */
|
/* find the hunk */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user