mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 02:43:03 +00:00
SImplify rpng_test.c
This commit is contained in:
parent
f04cb1deb9
commit
1bf6489da9
@ -35,40 +35,36 @@ static bool rpng_nbio_load_image_argb(const char *path, uint32_t **data,
|
||||
{
|
||||
size_t file_len;
|
||||
bool ret = true;
|
||||
struct nbio_t* handle = NULL;
|
||||
struct rpng_t *rpng = (struct rpng_t*)calloc(1, sizeof(struct rpng_t));
|
||||
|
||||
if (!rpng)
|
||||
return false;
|
||||
|
||||
rpng->userdata = (void*)nbio_open(path, NBIO_READ);
|
||||
|
||||
handle = (struct nbio_t*)rpng->userdata;
|
||||
struct rpng_t *rpng = NULL;
|
||||
void *ptr = NULL;
|
||||
struct nbio_t* handle = (void*)nbio_open(path, NBIO_READ);
|
||||
|
||||
if (!handle)
|
||||
goto end;
|
||||
|
||||
rpng->ptr = nbio_get_ptr(handle, &file_len);
|
||||
ptr = nbio_get_ptr(handle, &file_len);
|
||||
|
||||
nbio_begin_read(handle);
|
||||
|
||||
while (!nbio_iterate(handle));
|
||||
|
||||
ptr = nbio_get_ptr(handle, &file_len);
|
||||
|
||||
if (!ptr)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
rpng = (struct rpng_t*)calloc(1, sizeof(struct rpng_t));
|
||||
|
||||
if (!rpng)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
while (!nbio_iterate(handle));
|
||||
|
||||
rpng->ptr = nbio_get_ptr(handle, &file_len);
|
||||
|
||||
if (!rpng->ptr)
|
||||
{
|
||||
ret = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
rpng->buff_data = (uint8_t*)rpng->ptr;
|
||||
rpng->buff_data = (uint8_t*)ptr;
|
||||
|
||||
if (!rpng->buff_data)
|
||||
{
|
||||
@ -103,15 +99,13 @@ static bool rpng_nbio_load_image_argb(const char *path, uint32_t **data,
|
||||
rpng_nbio_load_image_argb_process(rpng, data, width, height);
|
||||
|
||||
end:
|
||||
if (rpng->userdata)
|
||||
nbio_free((struct nbio_t*)rpng->userdata);
|
||||
if (handle)
|
||||
nbio_free(handle);
|
||||
if (rpng)
|
||||
{
|
||||
rpng_nbio_load_image_free(rpng);
|
||||
}
|
||||
rpng = NULL;
|
||||
if (!ret)
|
||||
free(*data);
|
||||
rpng = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,6 @@ struct rpng_t
|
||||
uint8_t *buff_data;
|
||||
uint32_t palette[256];
|
||||
struct png_chunk chunk;
|
||||
void *userdata;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
bool rpng_load_image_argb(const char *path, uint32_t **data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user