-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA18-5-7.cpp
More file actions
50 lines (42 loc) · 1.03 KB
/
A18-5-7.cpp
File metadata and controls
50 lines (42 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Rule: A18-5-7
// Source line: 29989
// Original file: A18-5-7.cpp
//% $Id: A18-5-7.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
#include <memory>
#include <vector>
std::int8_t AppMainLoop() noexcept
{
std::int8_t retCode = 0;
std::int32_t* arr[10];
while (true)
{
for (std::int8_t i = 0; i < 10; ++i)
{
arr[i] = new std::int32_t{
i}; // Non-compliant - allocation in a phase that
// requires real-time
}
// Implementation
for (auto& i : arr)
{
delete i; // Non-compliant - deallocation in a phase that requires
// real-time
}
}
return retCode;
}
static std::int32_t* object =
new std::int32_t{0}; // Compliant- allocating in start-up phase
int main(int, char**)
{
std::unique_ptr<std::int32_t> ptr =
std::make_unique<std::int32_t>(0);
std::vector<std::int32_t> vec;
vec.reserve(10);
// Compliant
// Compliant
// Compliant
std::int8_t code = AppMainLoop();
return code;
}