Coverage Report

Created: 2025-12-19 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/brotli/c/dec/static_init.c
Line
Count
Source
1
/* Copyright 2025 Google Inc. All Rights Reserved.
2
3
   Distributed under MIT license.
4
   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5
*/
6
7
#include "static_init.h"
8
9
#include "../common/platform.h"
10
#include "../common/static_init.h"
11
12
#if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)
13
#include "../common/dictionary.h"
14
#include "prefix.h"
15
#endif
16
17
#if defined(__cplusplus) || defined(c_plusplus)
18
extern "C" {
19
#endif
20
21
#if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE)
22
static BROTLI_BOOL DoBrotliDecoderStaticInit(void) {
23
  BROTLI_BOOL ok = BrotliDecoderInitCmdLut(kCmdLut);
24
  if (!ok) return BROTLI_FALSE;
25
  return BROTLI_TRUE;
26
}
27
#endif  /* BROTLI_STATIC_INIT_NONE */
28
29
#if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)
30
static BROTLI_BOOL kEarlyInitOk;
31
static __attribute__((constructor)) void BrotliDecoderStaticInitEarly(void) {
32
  kEarlyInitOk = DoBrotliDecoderStaticInit();
33
}
34
#elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_LAZY)
35
static BROTLI_BOOL kLazyInitOk;
36
void BrotliDecoderLazyStaticInitInner(void) {
37
  kLazyInitOk = DoBrotliDecoderStaticInit();
38
}
39
#endif  /* BROTLI_STATIC_INIT_EARLY */
40
41
5.10k
BROTLI_BOOL BrotliDecoderEnsureStaticInit(void) {
42
5.10k
#if (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_NONE)
43
5.10k
  return BROTLI_TRUE;
44
#elif (BROTLI_STATIC_INIT == BROTLI_STATIC_INIT_EARLY)
45
  return kEarlyInitOk;
46
#else
47
  return kLazyInitOk;
48
#endif
49
5.10k
}
50
51
#if defined(__cplusplus) || defined(c_plusplus)
52
}  /* extern "C" */
53
#endif