• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bblanchon / ArduinoJson / 10572597112

27 Aug 2024 06:03AM UTC coverage: 99.194% (-0.3%) from 99.512%
10572597112

push

github

bblanchon
Merge conf_test for linux and windows

This reverts commit 83516e174.

3940 of 3972 relevant lines covered (99.19%)

10537.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/ArduinoJson/Memory/ResourceManagerImpl.hpp
1
// ArduinoJson - https://arduinojson.org
2
// Copyright © 2014-2024, Benoit BLANCHON
3
// MIT License
4

5
#pragma once
6

7
#include <ArduinoJson/Collection/CollectionData.hpp>
8
#include <ArduinoJson/Memory/ResourceManager.hpp>
9
#include <ArduinoJson/Polyfills/alias_cast.hpp>
10
#include <ArduinoJson/Variant/VariantData.hpp>
11

12
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
13

14
inline Slot<VariantData> ResourceManager::allocVariant() {
74,709✔
15
  auto p = variantPools_.allocSlot(allocator_);
74,709✔
16
  if (!p) {
74,709✔
17
    overflowed_ = true;
39✔
18
    return {};
39✔
19
  }
20
  return {new (&p->variant) VariantData, p.id()};
74,670✔
21
}
22

23
inline void ResourceManager::freeVariant(Slot<VariantData> variant) {
366✔
24
  variant->clear(this);
366✔
25
  variantPools_.freeSlot({alias_cast<SlotData*>(variant.ptr()), variant.id()});
366✔
26
}
366✔
27

28
inline VariantData* ResourceManager::getVariant(SlotId id) const {
365,857✔
29
  return reinterpret_cast<VariantData*>(variantPools_.getSlot(id));
365,857✔
30
}
31

32
#if ARDUINOJSON_USE_EXTENSIONS
33
inline Slot<VariantExtension> ResourceManager::allocExtension() {
122✔
34
  auto p = variantPools_.allocSlot(allocator_);
122✔
35
  if (!p) {
122✔
36
    overflowed_ = true;
×
37
    return {};
×
38
  }
39
  return {&p->extension, p.id()};
122✔
40
}
41

42
inline void ResourceManager::freeExtension(SlotId id) {
×
43
  auto p = getExtension(id);
×
44
  variantPools_.freeSlot({reinterpret_cast<SlotData*>(p), id});
×
45
}
×
46

47
inline VariantExtension* ResourceManager::getExtension(SlotId id) const {
137✔
48
  return &variantPools_.getSlot(id)->extension;
137✔
49
}
50
#endif
51

52
ARDUINOJSON_END_PRIVATE_NAMESPACE
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc