Coverage Report

Created: 2026-01-09 06:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aspell/common/cache.hpp
Line
Count
Source
1
#ifndef ACOMMON_CACHE__HPP
2
#define ACOMMON_CACHE__HPP
3
4
#include "posib_err.hpp"
5
6
namespace acommon {
7
8
class GlobalCacheBase;
9
template <class Data> class GlobalCache;
10
11
// get_cache_data (both versions) and release_cache_data will acquires
12
// the cache's lock
13
14
template <class Data>
15
PosibErr<Data *> get_cache_data(GlobalCache<Data> *, 
16
                                typename Data::CacheConfig *, 
17
                                const typename Data::CacheKey &);
18
template <class Data>
19
PosibErr<Data *> get_cache_data(GlobalCache<Data> *, 
20
                                typename Data::CacheConfig *, 
21
                                typename Data::CacheConfig2 *, 
22
                                const typename Data::CacheKey &);
23
24
class Cacheable;
25
void release_cache_data(GlobalCacheBase *, const Cacheable *);
26
static inline void release_cache_data(const GlobalCacheBase * c, const Cacheable * d)
27
0
{
28
0
  release_cache_data(const_cast<GlobalCacheBase *>(c),d);
29
0
}
Unexecuted instantiation: string_enumeration-c.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: speller-c.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: new_checker.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: config.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: convert.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: document_checker.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: basic.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: new_filter.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: new_fmode.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: find_speller.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: email.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: tex.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: cache.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: tokenizer.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: speller_impl.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: language.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: affix.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: speller.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: suggest.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: data.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: multi_ws.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: phonetic.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: writable.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: phonet.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: typo_editdist.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
Unexecuted instantiation: readonly_ws.cpp:acommon::release_cache_data(acommon::GlobalCacheBase const*, acommon::Cacheable const*)
30
31
class Cacheable
32
{
33
public: // but don't use
34
  Cacheable * next;
35
  Cacheable * * prev;
36
  mutable int refcount;
37
  GlobalCacheBase * cache;
38
public:
39
16.9k
  bool attached() {return prev;}
40
1.04k
  void copy_no_lock() const {refcount++;}
41
  void copy() const; // Acquires cache->lock
42
45.3k
  void release() const {release_cache_data(cache,this);} // Acquires cache->lock
43
33.4k
  Cacheable(GlobalCacheBase * c = 0) : next(0), prev(0), refcount(1), cache(c) {}
44
33.4k
  virtual ~Cacheable() {}
45
};
46
47
template <class Data>
48
class CachePtr
49
{
50
  Data * ptr;
51
52
public:
53
91.5k
  void reset(Data * p) {
54
91.5k
    if (ptr) ptr->release();
55
91.5k
    ptr = p;
56
91.5k
  }
acommon::CachePtr<acommon::Decode>::reset(acommon::Decode*)
Line
Count
Source
53
15.9k
  void reset(Data * p) {
54
15.9k
    if (ptr) ptr->release();
55
15.9k
    ptr = p;
56
15.9k
  }
acommon::CachePtr<acommon::Encode>::reset(acommon::Encode*)
Line
Count
Source
53
21.8k
  void reset(Data * p) {
54
21.8k
    if (ptr) ptr->release();
55
21.8k
    ptr = p;
56
21.8k
  }
acommon::CachePtr<acommon::NormTables>::reset(acommon::NormTables*)
Line
Count
Source
53
24.2k
  void reset(Data * p) {
54
24.2k
    if (ptr) ptr->release();
55
24.2k
    ptr = p;
56
24.2k
  }
acommon::CachePtr<acommon::FilterModeList>::reset(acommon::FilterModeList*)
Line
Count
Source
53
8.73k
  void reset(Data * p) {
54
8.73k
    if (ptr) ptr->release();
55
8.73k
    ptr = p;
56
8.73k
  }
acommon::CachePtr<aspeller::Language const>::reset(aspeller::Language const*)
Line
Count
Source
53
16.5k
  void reset(Data * p) {
54
16.5k
    if (ptr) ptr->release();
55
16.5k
    ptr = p;
56
16.5k
  }
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::reset(aspeller::TypoEditDistanceInfo const*)
Line
Count
Source
53
4.06k
  void reset(Data * p) {
54
4.06k
    if (ptr) ptr->release();
55
4.06k
    ptr = p;
56
4.06k
  }
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::reset(aspeller::Language*)
57
1.04k
  void copy(Data * p) {if (p) p->copy(); reset(p);}
58
  Data * release() {Data * tmp = ptr; ptr = 0; return tmp;}
59
60
5.33M
  Data & operator*  () const {return *ptr;}
acommon::CachePtr<aspeller::Language const>::operator*() const
Line
Count
Source
60
17.6k
  Data & operator*  () const {return *ptr;}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::operator*() const
Line
Count
Source
60
5.31M
  Data & operator*  () const {return *ptr;}
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::operator*() const
61
9.58M
  Data * operator-> () const {return ptr;}
acommon::CachePtr<acommon::NormTables>::operator->() const
Line
Count
Source
61
38.5k
  Data * operator-> () const {return ptr;}
acommon::CachePtr<aspeller::Language const>::operator->() const
Line
Count
Source
61
1.95M
  Data * operator-> () const {return ptr;}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::operator->() const
Line
Count
Source
61
7.59M
  Data * operator-> () const {return ptr;}
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::operator->() const
62
17.2k
  Data * get()         const {return ptr;}
acommon::CachePtr<acommon::Decode>::get() const
Line
Count
Source
62
3.52k
  Data * get()         const {return ptr;}
acommon::CachePtr<acommon::Encode>::get() const
Line
Count
Source
62
9.46k
  Data * get()         const {return ptr;}
acommon::CachePtr<acommon::FilterModeList>::get() const
Line
Count
Source
62
4.28k
  Data * get()         const {return ptr;}
63
111k
  operator Data * ()   const {return ptr;}
acommon::CachePtr<acommon::FilterModeList>::operator acommon::FilterModeList*() const
Line
Count
Source
63
4.28k
  operator Data * ()   const {return ptr;}
acommon::CachePtr<aspeller::Language const>::operator aspeller::Language const*() const
Line
Count
Source
63
107k
  operator Data * ()   const {return ptr;}
64
65
49.9k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::Decode>::CachePtr()
Line
Count
Source
65
12.4k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::Encode>::CachePtr()
Line
Count
Source
65
12.4k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::NormTables>::CachePtr()
Line
Count
Source
65
12.4k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::FilterModeList>::CachePtr()
Line
Count
Source
65
2.32k
  CachePtr() : ptr(0) {}
acommon::CachePtr<aspeller::Language const>::CachePtr()
Line
Count
Source
65
8.30k
  CachePtr() : ptr(0) {}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::CachePtr()
Line
Count
Source
65
2.03k
  CachePtr() : ptr(0) {}
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::CachePtr()
66
0
  CachePtr(const CachePtr & other) {ptr = other.ptr; if (ptr) ptr->copy();}
67
  void operator=(const CachePtr & other) {copy(other.ptr);}
68
49.9k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::Decode>::~CachePtr()
Line
Count
Source
68
12.4k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::Encode>::~CachePtr()
Line
Count
Source
68
12.4k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::NormTables>::~CachePtr()
Line
Count
Source
68
12.4k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::FilterModeList>::~CachePtr()
Line
Count
Source
68
2.32k
  ~CachePtr() {reset(0);}
acommon::CachePtr<aspeller::Language const>::~CachePtr()
Line
Count
Source
68
8.30k
  ~CachePtr() {reset(0);}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::~CachePtr()
Line
Count
Source
68
2.03k
  ~CachePtr() {reset(0);}
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::~CachePtr()
69
};
70
71
template <class Data>
72
PosibErr<void> setup(CachePtr<Data> & res,
73
                     GlobalCache<Data> * cache, 
74
                     typename Data::CacheConfig * config, 
75
27.8k
                     const typename Data::CacheKey & key) {
76
27.8k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
27.8k
  if (pe.has_err()) return pe;
78
27.7k
  res.reset(pe.data);
79
27.7k
  return no_err;
80
27.8k
}
acommon::PosibErr<void> acommon::setup<acommon::Decode>(acommon::CachePtr<acommon::Decode>&, acommon::GlobalCache<acommon::Decode>*, acommon::Decode::CacheConfig*, acommon::Decode::CacheKey const&)
Line
Count
Source
75
3.54k
                     const typename Data::CacheKey & key) {
76
3.54k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
3.54k
  if (pe.has_err()) return pe;
78
3.52k
  res.reset(pe.data);
79
3.52k
  return no_err;
80
3.54k
}
acommon::PosibErr<void> acommon::setup<acommon::Encode>(acommon::CachePtr<acommon::Encode>&, acommon::GlobalCache<acommon::Encode>*, acommon::Encode::CacheConfig*, acommon::Encode::CacheKey const&)
Line
Count
Source
75
9.46k
                     const typename Data::CacheKey & key) {
76
9.46k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
9.46k
  if (pe.has_err()) return pe;
78
9.46k
  res.reset(pe.data);
79
9.46k
  return no_err;
80
9.46k
}
acommon::PosibErr<void> acommon::setup<acommon::NormTables>(acommon::CachePtr<acommon::NormTables>&, acommon::GlobalCache<acommon::NormTables>*, acommon::NormTables::CacheConfig*, acommon::NormTables::CacheKey const&)
Line
Count
Source
75
11.8k
                     const typename Data::CacheKey & key) {
76
11.8k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
11.8k
  if (pe.has_err()) return pe;
78
11.8k
  res.reset(pe.data);
79
11.8k
  return no_err;
80
11.8k
}
acommon::PosibErr<void> acommon::setup<acommon::FilterModeList>(acommon::CachePtr<acommon::FilterModeList>&, acommon::GlobalCache<acommon::FilterModeList>*, acommon::FilterModeList::CacheConfig*, acommon::FilterModeList::CacheKey const&)
Line
Count
Source
75
2.96k
                     const typename Data::CacheKey & key) {
76
2.96k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
2.96k
  if (pe.has_err()) return pe;
78
2.96k
  res.reset(pe.data);
79
2.96k
  return no_err;
80
2.96k
}
81
82
bool reset_cache(const char * = 0);
83
84
}
85
86
#endif