mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-16 13:59:51 +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:
@ -723,7 +723,8 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
||||
// bin_map[n][num_histo + 1] ... bin_map[n][bin_depth - 1] = un-used indices.
|
||||
const int bin_depth = histo_image_raw_size + 1;
|
||||
int16_t* bin_map = NULL;
|
||||
VP8LHistogram* const histos = (VP8LHistogram*)malloc(2 * sizeof(*histos));
|
||||
VP8LHistogram* const histos =
|
||||
(VP8LHistogram*)WebPSafeMalloc(2ULL, sizeof(*histos));
|
||||
VP8LHistogramSet* const init_histo =
|
||||
VP8LAllocateHistogramSet(histo_image_raw_size, cache_bits);
|
||||
|
||||
@ -760,8 +761,8 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
||||
ok = 1;
|
||||
|
||||
Error:
|
||||
free(bin_map);
|
||||
free(init_histo);
|
||||
free(histos);
|
||||
WebPSafeFree(bin_map);
|
||||
WebPSafeFree(init_histo);
|
||||
WebPSafeFree(histos);
|
||||
return ok;
|
||||
}
|
||||
|
Reference in New Issue
Block a user