Coverage Report

Created: 2025-11-16 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjxl/lib/jpegli/memory_manager.h
Line
Count
Source
1
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
2
//
3
// Use of this source code is governed by a BSD-style
4
// license that can be found in the LICENSE file.
5
6
#ifndef LIB_JPEGLI_MEMORY_MANAGER_H_
7
#define LIB_JPEGLI_MEMORY_MANAGER_H_
8
9
#include <cstdlib>
10
11
#include "lib/jpegli/common.h"
12
13
#define JPOOL_PERMANENT_ALIGNED (JPOOL_NUMPOOLS + JPOOL_PERMANENT)
14
37.3k
#define JPOOL_IMAGE_ALIGNED (JPOOL_NUMPOOLS + JPOOL_IMAGE)
15
16
namespace jpegli {
17
18
void InitMemoryManager(j_common_ptr cinfo);
19
20
template <typename T>
21
95.6k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
95.6k
  const size_t size = len * sizeof(T);  // NOLINT
23
95.6k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
95.6k
  return reinterpret_cast<T*>(p);
25
95.6k
}
JQUANT_TBL* jpegli::Allocate<JQUANT_TBL>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
8.04k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
8.04k
  const size_t size = len * sizeof(T);  // NOLINT
23
8.04k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
8.04k
  return reinterpret_cast<T*>(p);
25
8.04k
}
JHUFF_TBL* jpegli::Allocate<JHUFF_TBL>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
13.9k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
13.9k
  const size_t size = len * sizeof(T);  // NOLINT
23
13.9k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
13.9k
  return reinterpret_cast<T*>(p);
25
13.9k
}
unsigned char* jpegli::Allocate<unsigned char>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
3.18k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
3.18k
  const size_t size = len * sizeof(T);  // NOLINT
23
3.18k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
3.18k
  return reinterpret_cast<T*>(p);
25
3.18k
}
Unexecuted instantiation: unsigned char** jpegli::Allocate<unsigned char*>(jpeg_common_struct*, unsigned long, int)
jvirt_barray_control** jpegli::Allocate<jvirt_barray_control*>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
3.37k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
3.37k
  const size_t size = len * sizeof(T);  // NOLINT
23
3.37k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
3.37k
  return reinterpret_cast<T*>(p);
25
3.37k
}
float* jpegli::Allocate<float>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
24.5k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
24.5k
  const size_t size = len * sizeof(T);  // NOLINT
23
24.5k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
24.5k
  return reinterpret_cast<T*>(p);
25
24.5k
}
short* jpegli::Allocate<short>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
3.18k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
3.18k
  const size_t size = len * sizeof(T);  // NOLINT
23
3.18k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
3.18k
  return reinterpret_cast<T*>(p);
25
3.18k
}
int* jpegli::Allocate<int>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
6.36k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
6.36k
  const size_t size = len * sizeof(T);  // NOLINT
23
6.36k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
6.36k
  return reinterpret_cast<T*>(p);
25
6.36k
}
Unexecuted instantiation: jpeg_marker_struct* jpegli::Allocate<jpeg_marker_struct>(jpeg_common_struct*, unsigned long, int)
jpeg_component_info* jpegli::Allocate<jpeg_component_info>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
3.70k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
3.70k
  const size_t size = len * sizeof(T);  // NOLINT
23
3.70k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
3.70k
  return reinterpret_cast<T*>(p);
25
3.70k
}
int (*jpegli::Allocate<int [64]>(jpeg_common_struct*, unsigned long, int)) [64]
Line
Count
Source
21
3.42k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
3.42k
  const size_t size = len * sizeof(T);  // NOLINT
23
3.42k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
3.42k
  return reinterpret_cast<T*>(p);
25
3.42k
}
int (*jpegli::Allocate<int [10]>(jpeg_common_struct*, unsigned long, int)) [10]
Line
Count
Source
21
6.84k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
6.84k
  const size_t size = len * sizeof(T);  // NOLINT
23
6.84k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
6.84k
  return reinterpret_cast<T*>(p);
25
6.84k
}
short (**jpegli::Allocate<short (*) [64]>(jpeg_common_struct*, unsigned long, int)) [64]
Line
Count
Source
21
6.30k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
6.30k
  const size_t size = len * sizeof(T);  // NOLINT
23
6.30k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
6.30k
  return reinterpret_cast<T*>(p);
25
6.30k
}
short (*jpegli::Allocate<short [64]>(jpeg_common_struct*, unsigned long, int)) [64]
Line
Count
Source
21
6.30k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
6.30k
  const size_t size = len * sizeof(T);  // NOLINT
23
6.30k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
6.30k
  return reinterpret_cast<T*>(p);
25
6.30k
}
Unexecuted instantiation: jvirt_sarray_control* jpegli::Allocate<jvirt_sarray_control>(jpeg_common_struct*, unsigned long, int)
jvirt_barray_control* jpegli::Allocate<jvirt_barray_control>(jpeg_common_struct*, unsigned long, int)
Line
Count
Source
21
6.30k
T* Allocate(j_common_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
22
6.30k
  const size_t size = len * sizeof(T);  // NOLINT
23
6.30k
  void* p = (*cinfo->mem->alloc_small)(cinfo, pool_id, size);
24
6.30k
  return reinterpret_cast<T*>(p);
25
6.30k
}
26
27
template <typename T>
28
59.2k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
59.2k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
59.2k
}
JQUANT_TBL* jpegli::Allocate<JQUANT_TBL>(jpeg_decompress_struct*, unsigned long, int)
Line
Count
Source
28
4.61k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
4.61k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
4.61k
}
unsigned char* jpegli::Allocate<unsigned char>(jpeg_decompress_struct*, unsigned long, int)
Line
Count
Source
28
3.18k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
3.18k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
3.18k
}
Unexecuted instantiation: unsigned char** jpegli::Allocate<unsigned char*>(jpeg_decompress_struct*, unsigned long, int)
jvirt_barray_control** jpegli::Allocate<jvirt_barray_control*>(jpeg_decompress_struct*, unsigned long, int)
Line
Count
Source
28
3.37k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
3.37k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
3.37k
}
float* jpegli::Allocate<float>(jpeg_decompress_struct*, unsigned long, int)
Line
Count
Source
28
24.5k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
24.5k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
24.5k
}
short* jpegli::Allocate<short>(jpeg_decompress_struct*, unsigned long, int)
Line
Count
Source
28
3.18k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
3.18k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
3.18k
}
int* jpegli::Allocate<int>(jpeg_decompress_struct*, unsigned long, int)
Line
Count
Source
28
6.36k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
6.36k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
6.36k
}
Unexecuted instantiation: jpeg_marker_struct* jpegli::Allocate<jpeg_marker_struct>(jpeg_decompress_struct*, unsigned long, int)
jpeg_component_info* jpegli::Allocate<jpeg_component_info>(jpeg_decompress_struct*, unsigned long, int)
Line
Count
Source
28
3.70k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
3.70k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
3.70k
}
int (*jpegli::Allocate<int [64]>(jpeg_decompress_struct*, unsigned long, int)) [64]
Line
Count
Source
28
3.42k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
3.42k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
3.42k
}
int (*jpegli::Allocate<int [10]>(jpeg_decompress_struct*, unsigned long, int)) [10]
Line
Count
Source
28
6.84k
T* Allocate(j_decompress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
29
6.84k
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
30
6.84k
}
31
32
template <typename T>
33
T* Allocate(j_compress_ptr cinfo, size_t len, int pool_id = JPOOL_PERMANENT) {
34
  return Allocate<T>(reinterpret_cast<j_common_ptr>(cinfo), len, pool_id);
35
}
36
37
template <typename T>
38
JBLOCKARRAY GetBlockRow(T cinfo, int c, JDIMENSION by) {
39
  return (*cinfo->mem->access_virt_barray)(
40
      reinterpret_cast<j_common_ptr>(cinfo), cinfo->master->coeff_buffers[c],
41
      by, 1, true);
42
}
43
44
}  // namespace jpegli
45
46
#endif  // LIB_JPEGLI_MEMORY_MANAGER_H_