]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/tools/lldb-mi/MIUtilMapIdToVariant.cpp
Fix a memory leak in if_delgroups() introduced in r334118.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / tools / lldb-mi / MIUtilMapIdToVariant.cpp
1 //===-- MIUtilMapIdToVariant.cpp --------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // In-house headers:
10 #include "MIUtilMapIdToVariant.h"
11
12 //++
13 // Details: CMIUtilMapIdToVariant constructor.
14 // Type:    Method.
15 // Args:    None.
16 // Return:  None.
17 // Throws:  None.
18 //--
19 CMIUtilMapIdToVariant::CMIUtilMapIdToVariant() {}
20
21 //++
22 // Details: CMIUtilMapIdToVariant destructor.
23 // Type:    Method.
24 // Args:    None.
25 // Return:  None.
26 // Throws:  None.
27 //--
28 CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant() {}
29
30 //++
31 // Details: Remove at the data from *this container.
32 // Type:    Method.
33 // Args:    None.
34 // Return:  None.
35 // Throws:  None.
36 //--
37 void CMIUtilMapIdToVariant::Clear() { m_mapKeyToVariantValue.clear(); }
38
39 //++
40 // Details: Check an ID is present already in *this container.
41 // Type:    Method.
42 // Args:    vId - (R) Unique ID i.e. GUID.
43 // Return:  True - registered.
44 //          False - not found.
45 // Throws:  None.
46 //--
47 bool CMIUtilMapIdToVariant::HaveAlready(const CMIUtilString &vId) const {
48   const MapKeyToVariantValue_t::const_iterator it =
49       m_mapKeyToVariantValue.find(vId);
50   return it != m_mapKeyToVariantValue.end();
51 }
52
53 //++
54 // Details: Determine if *this container is currently holding any data.
55 // Type:    Method.
56 // Args:    None.
57 // Return:  bool    - True - Yes empty, false - one or more data object present.
58 // Throws:  None.
59 //--
60 bool CMIUtilMapIdToVariant::IsEmpty() const {
61   return m_mapKeyToVariantValue.empty();
62 }
63
64 //++
65 // Details: Check the ID is valid to be registered.
66 // Type:    Method.
67 // Args:    vId - (R) Unique ID i.e. GUID.
68 // Return:  True - valid.
69 //          False - not valid.
70 // Throws:  None.
71 //--
72 bool CMIUtilMapIdToVariant::IsValid(const CMIUtilString &vId) const {
73   bool bValid = true;
74
75   if (vId.empty())
76     bValid = false;
77
78   return bValid;
79 }
80
81 //++
82 // Details: Remove from *this contain a data object specified by ID. The data
83 // object
84 //          when removed also calls its destructor should it have one.
85 // Type:    Method.
86 // Args:    vId - (R) Unique ID i.e. GUID.
87 // Return:  MIstatus::success - Functional succeeded.
88 //          MIstatus::failure - Functional failed.
89 // Throws:  None.
90 //--
91 bool CMIUtilMapIdToVariant::Remove(const CMIUtilString &vId) {
92   const MapKeyToVariantValue_t::const_iterator it =
93       m_mapKeyToVariantValue.find(vId);
94   if (it != m_mapKeyToVariantValue.end()) {
95     m_mapKeyToVariantValue.erase(it);
96   }
97
98   return MIstatus::success;
99 }