mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +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:
@ -66,7 +66,7 @@ static int TreeInit(HuffmanTree* const tree, int num_leaves) {
|
||||
|
||||
void HuffmanTreeRelease(HuffmanTree* const tree) {
|
||||
if (tree != NULL) {
|
||||
free(tree->root_);
|
||||
WebPSafeFree(tree->root_);
|
||||
tree->root_ = NULL;
|
||||
tree->max_nodes_ = 0;
|
||||
tree->num_nodes_ = 0;
|
||||
@ -245,7 +245,7 @@ int HuffmanTreeBuildImplicit(HuffmanTree* const tree,
|
||||
}
|
||||
ok = 1;
|
||||
End:
|
||||
free(codes);
|
||||
WebPSafeFree(codes);
|
||||
ok = ok && IsFull(tree);
|
||||
if (!ok) HuffmanTreeRelease(tree);
|
||||
return ok;
|
||||
|
Reference in New Issue
Block a user