Coverage Report

Created: 2026-01-13 06:34

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
15.5k
  bool attached() {return prev;}
40
940
  void copy_no_lock() const {refcount++;}
41
  void copy() const; // Acquires cache->lock
42
41.1k
  void release() const {release_cache_data(cache,this);} // Acquires cache->lock
43
31.3k
  Cacheable(GlobalCacheBase * c = 0) : next(0), prev(0), refcount(1), cache(c) {}
44
31.3k
  virtual ~Cacheable() {}
45
};
46
47
template <class Data>
48
class CachePtr
49
{
50
  Data * ptr;
51
52
public:
53
83.0k
  void reset(Data * p) {
54
83.0k
    if (ptr) ptr->release();
55
83.0k
    ptr = p;
56
83.0k
  }
acommon::CachePtr<acommon::Decode>::reset(acommon::Decode*)
Line
Count
Source
53
14.4k
  void reset(Data * p) {
54
14.4k
    if (ptr) ptr->release();
55
14.4k
    ptr = p;
56
14.4k
  }
acommon::CachePtr<acommon::Encode>::reset(acommon::Encode*)
Line
Count
Source
53
19.7k
  void reset(Data * p) {
54
19.7k
    if (ptr) ptr->release();
55
19.7k
    ptr = p;
56
19.7k
  }
acommon::CachePtr<acommon::NormTables>::reset(acommon::NormTables*)
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::FilterModeList>::reset(acommon::FilterModeList*)
Line
Count
Source
53
8.41k
  void reset(Data * p) {
54
8.41k
    if (ptr) ptr->release();
55
8.41k
    ptr = p;
56
8.41k
  }
acommon::CachePtr<aspeller::Language const>::reset(aspeller::Language const*)
Line
Count
Source
53
14.9k
  void reset(Data * p) {
54
14.9k
    if (ptr) ptr->release();
55
14.9k
    ptr = p;
56
14.9k
  }
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::reset(aspeller::TypoEditDistanceInfo const*)
Line
Count
Source
53
3.61k
  void reset(Data * p) {
54
3.61k
    if (ptr) ptr->release();
55
3.61k
    ptr = p;
56
3.61k
  }
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::reset(aspeller::Language*)
57
940
  void copy(Data * p) {if (p) p->copy(); reset(p);}
58
  Data * release() {Data * tmp = ptr; ptr = 0; return tmp;}
59
60
2.56M
  Data & operator*  () const {return *ptr;}
acommon::CachePtr<aspeller::Language const>::operator*() const
Line
Count
Source
60
15.7k
  Data & operator*  () const {return *ptr;}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::operator*() const
Line
Count
Source
60
2.54M
  Data & operator*  () const {return *ptr;}
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::operator*() const
61
5.20M
  Data * operator-> () const {return ptr;}
acommon::CachePtr<acommon::NormTables>::operator->() const
Line
Count
Source
61
34.4k
  Data * operator-> () const {return ptr;}
acommon::CachePtr<aspeller::Language const>::operator->() const
Line
Count
Source
61
1.28M
  Data * operator-> () const {return ptr;}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::operator->() const
Line
Count
Source
61
3.88M
  Data * operator-> () const {return ptr;}
Unexecuted instantiation: acommon::CachePtr<aspeller::Language>::operator->() const
62
16.2k
  Data * get()         const {return ptr;}
acommon::CachePtr<acommon::Decode>::get() const
Line
Count
Source
62
3.24k
  Data * get()         const {return ptr;}
acommon::CachePtr<acommon::Encode>::get() const
Line
Count
Source
62
8.56k
  Data * get()         const {return ptr;}
acommon::CachePtr<acommon::FilterModeList>::get() const
Line
Count
Source
62
4.41k
  Data * get()         const {return ptr;}
63
101k
  operator Data * ()   const {return ptr;}
acommon::CachePtr<acommon::FilterModeList>::operator acommon::FilterModeList*() const
Line
Count
Source
63
4.41k
  operator Data * ()   const {return ptr;}
acommon::CachePtr<aspeller::Language const>::operator aspeller::Language const*() const
Line
Count
Source
63
96.7k
  operator Data * ()   const {return ptr;}
64
65
45.0k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::Decode>::CachePtr()
Line
Count
Source
65
11.2k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::Encode>::CachePtr()
Line
Count
Source
65
11.2k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::NormTables>::CachePtr()
Line
Count
Source
65
11.2k
  CachePtr() : ptr(0) {}
acommon::CachePtr<acommon::FilterModeList>::CachePtr()
Line
Count
Source
65
2.11k
  CachePtr() : ptr(0) {}
acommon::CachePtr<aspeller::Language const>::CachePtr()
Line
Count
Source
65
7.48k
  CachePtr() : ptr(0) {}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::CachePtr()
Line
Count
Source
65
1.81k
  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
45.0k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::Decode>::~CachePtr()
Line
Count
Source
68
11.2k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::Encode>::~CachePtr()
Line
Count
Source
68
11.2k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::NormTables>::~CachePtr()
Line
Count
Source
68
11.2k
  ~CachePtr() {reset(0);}
acommon::CachePtr<acommon::FilterModeList>::~CachePtr()
Line
Count
Source
68
2.11k
  ~CachePtr() {reset(0);}
acommon::CachePtr<aspeller::Language const>::~CachePtr()
Line
Count
Source
68
7.48k
  ~CachePtr() {reset(0);}
acommon::CachePtr<aspeller::TypoEditDistanceInfo const>::~CachePtr()
Line
Count
Source
68
1.81k
  ~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
25.3k
                     const typename Data::CacheKey & key) {
76
25.3k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
25.3k
  if (pe.has_err()) return pe;
78
25.3k
  res.reset(pe.data);
79
25.3k
  return no_err;
80
25.3k
}
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.27k
                     const typename Data::CacheKey & key) {
76
3.27k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
3.27k
  if (pe.has_err()) return pe;
78
3.24k
  res.reset(pe.data);
79
3.24k
  return no_err;
80
3.27k
}
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
8.56k
                     const typename Data::CacheKey & key) {
76
8.56k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
8.56k
  if (pe.has_err()) return pe;
78
8.56k
  res.reset(pe.data);
79
8.56k
  return no_err;
80
8.56k
}
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
10.5k
                     const typename Data::CacheKey & key) {
76
10.5k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
10.5k
  if (pe.has_err()) return pe;
78
10.5k
  res.reset(pe.data);
79
10.5k
  return no_err;
80
10.5k
}
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.95k
                     const typename Data::CacheKey & key) {
76
2.95k
  PosibErr<Data *> pe = get_cache_data(cache, config, key);
77
2.95k
  if (pe.has_err()) return pe;
78
2.95k
  res.reset(pe.data);
79
2.95k
  return no_err;
80
2.95k
}
81
82
bool reset_cache(const char * = 0);
83
84
}
85
86
#endif