To make that possible these things were also done:
* Rename variables for clarity.
* Rename functions to separate them from jbig2dec's own allocator API.
* Consistently use size_t for all memory statistics.
* Add helper function for checking peak memory use.
* Add helper function for when limit is reached.
* Add helper function for when allocations fail.
* Add helper function for memory statis at end of run (including leak check).
This will help with fixing jbig2dec issue 21675 reported by OSS-fuzz.
Apparently the maximum memory usage is 2.5Gbyte so a limit of 3Gbyte
is to liberal. Set limit to 1Gbyte to make sure that any extra memory
used by the fuzzer is allowed. 1Gbyte ought to be enough for most real
world images decoded by jbig2dec.
* [jbig2dec] Fix issues in library glue logic.
This addresses the out of memory condition exhibited in
project-jbig2dec bug #17168.
* [jbig2dec] Print peak memory usage.
This would be helpful when we're approaching OOM conditions.