You can't replace jpeg_get_small(), jpeg_get_large(), jpeg_free_small(),
and jpeg_free_large() without customizing the libjpeg-turbo source code,
but you can replace the higher-level functions in jmemmgr.c at run time.
How you would do that is:
- Implement your own versions of jpeg_get_*() and jpeg_free_*() in your
own program. You can name these, for example, my_jpeg_get_*() and
my_jpeg_free_*(). You can just copy the function prototypes from
jmemnobs.c and change the function names.
- Implement your own versions of alloc_small(), alloc_large(),
free_pool(), and self_destruct() in your own program, using the code in
jmemmgr.c as a template (you can simply replace all calls to jpeg_*()
with calls to my_jpeg_*().)
- At run time, after calling jpeg_create_compress(), modify
cinfo->mem->[alloc_small|alloc_large|free_pool|self_destruct] to point
to your custom functions.