mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
use WebPSafe[CM]alloc/WebPSafeFree instead of [cm]alloc/free
there's still some malloc/free in the external example This is an encoder API change because of the introduction of WebPMemoryWriterClear() for symmetry reasons. The MemoryWriter object should probably go in examples/ instead of being in the main lib, though. mux_types.h stil contain some inlined free()/malloc() that are harder to remove (we need to put them in the libwebputils lib and make sure link is ok). Left as a TODO for now. Also: WebPDecodeRGB*() function are still returning a pointer that needs to be free()'d. We should call WebPSafeFree() on these, but it means exposing the whole mechanism. TODO(later). Change-Id: Iad2c9060f7fa6040e3ba489c8b07f4caadfab77b
This commit is contained in:
@ -1121,7 +1121,7 @@ int main(int argc, const char *argv[]) {
|
||||
return_value = 0;
|
||||
|
||||
Error:
|
||||
free(memory_writer.mem);
|
||||
WebPMemoryWriterClear(&memory_writer);
|
||||
free(picture.extra_info);
|
||||
MetadataFree(&metadata);
|
||||
WebPPictureFree(&picture);
|
||||
|
@ -469,10 +469,10 @@ static int SetFrame(const WebPConfig* const config, int allow_mixed,
|
||||
// TODO(later): Perhaps a rough SSIM/PSNR produced by the encoder should
|
||||
// also be a criteria, in addition to sizes.
|
||||
if (mem1.size <= mem2.size) {
|
||||
free(mem2.mem);
|
||||
WebPMemoryWriterClear(&mem2);
|
||||
GetEncodedData(&mem1, encoded_data);
|
||||
} else {
|
||||
free(mem1.mem);
|
||||
WebPMemoryWriterClear(&mem1);
|
||||
GetEncodedData(&mem2, encoded_data);
|
||||
}
|
||||
} else {
|
||||
@ -481,8 +481,8 @@ static int SetFrame(const WebPConfig* const config, int allow_mixed,
|
||||
return 1;
|
||||
|
||||
Err:
|
||||
free(mem1.mem);
|
||||
free(mem2.mem);
|
||||
WebPMemoryWriterClear(&mem1);
|
||||
WebPMemoryWriterClear(&mem2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user