1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
This file is part of jpegxl-sys.
jpegxl-sys is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jpegxl-sys is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with jpegxl-sys. If not, see <https://www.gnu.org/licenses/>.
*/
//! Abstraction functions used by JPEG XL to allocate memory.
use c_void;
/// Allocating function for a memory region of a given size.
///
/// Allocates a contiguous memory region of size `size` bytes. The returned
/// memory may not be aligned to a specific size or initialized at all.
///
/// # Parameters
/// - `opaque`: custom memory manager handle provided by the caller.
/// - `size`: size in bytes of the requested memory region.
///
/// # Returns
/// - `NULL` if the memory cannot be allocated.
/// - Pointer to the memory otherwise.
pub type JpegxlAllocFunc =
unsafe extern "C-unwind" fn ;
/// Deallocating function pointer type.
///
/// This function **MUST** do nothing if `address` is `NULL`.
///
/// # Parameters
/// - `opaque`: custom memory manager handle provided by the caller.
/// - `address`: memory region pointer returned by [`JpegxlAllocFunc`], or `NULL`.
pub type JpegxlFreeFunc = unsafe extern "C-unwind" fn;
/// Memory Manager struct.
/// These functions, when provided by the caller, will be used to handle memory
/// allocations.