diff --git a/albumart.c b/albumart.c index 929055f..bd23e4e 100644 --- a/albumart.c +++ b/albumart.c @@ -78,18 +78,17 @@ save_resized_album_art(image_s *imsrc, const char *path) dstw = (imsrc->width<<8) / ((imsrc->height<<8)/160); dsth = 160; } - imdst = image_resize(imsrc, dstw, dsth); + imdst = image_resize(imsrc, dstw, dsth); if( !imdst ) - goto error; - - if( image_save_to_jpeg_file(imdst, cache_file) == 0 ) { - image_free(imdst); - return cache_file; + free(cache_file); + return NULL; } -error: - free(cache_file); - return NULL; + + cache_file = image_save_to_jpeg_file(imdst, cache_file); + image_free(imdst); + + return cache_file; } /* And our main album art functions */ diff --git a/image_utils.c b/image_utils.c index 6abdc96..c71fa77 100644 --- a/image_utils.c +++ b/image_utils.c @@ -838,8 +838,8 @@ image_save_to_jpeg_buf(image_s * pimage, int * size) return dst.buf; } -int -image_save_to_jpeg_file(image_s * pimage, const char * path) +char * +image_save_to_jpeg_file(image_s * pimage, char * path) { int nwritten, size = 0; unsigned char * buf; @@ -847,16 +847,16 @@ image_save_to_jpeg_file(image_s * pimage, const char * path) buf = image_save_to_jpeg_buf(pimage, &size); if( !buf ) - return -1; + return NULL; dst_file = fopen(path, "w"); if( !dst_file ) { free(buf); - return -1; + return NULL; } nwritten = fwrite(buf, 1, size, dst_file); fclose(dst_file); free(buf); - return (nwritten==size ? 0 : 1); + return (nwritten == size) ? path : NULL; } diff --git a/image_utils.h b/image_utils.h index 4c1a79f..10b2d75 100644 --- a/image_utils.h +++ b/image_utils.h @@ -54,5 +54,5 @@ image_resize(image_s * src_image, int32_t width, int32_t height); unsigned char * image_save_to_jpeg_buf(image_s * pimage, int * size); -int -image_save_to_jpeg_file(image_s * pimage, const char * path); +char * +image_save_to_jpeg_file(image_s * pimage, char * path);