Changeset 85936 in vbox
- Timestamp:
- Aug 28, 2020 4:54:48 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r85929 r85936 254 254 }; 255 255 256 class MediumProperty 257 { 258 public: 259 const char *m_pszKey; 260 const char *m_pszValue; /**< Can be binary too. */ 261 size_t m_cbValue; 262 char *m_pszFreeValue; 263 MediumProperty() : m_pszKey(NULL), m_pszValue(NULL), m_cbValue(0), m_pszFreeValue(NULL) { } 264 MediumProperty(MediumProperty const &a_rThat) 265 : m_pszKey(a_rThat.m_pszKey) 266 , m_pszValue(a_rThat.m_pszValue) 267 , m_cbValue(a_rThat.m_cbValue) 268 , m_pszFreeValue(NULL) 269 { 270 Assert(a_rThat.m_pszFreeValue == NULL); /* not expected here! */ 271 } 272 ~MediumProperty() 273 { 274 RTMemFree(m_pszFreeValue); 275 m_pszFreeValue = NULL; 276 } 277 278 private: 279 MediumProperty &operator=(MediumProperty const &a_rThat) 280 { 281 m_pszKey = a_rThat.m_pszKey; 282 m_pszValue = a_rThat.m_pszValue; 283 m_cbValue = a_rThat.m_cbValue; 284 m_pszFreeValue = a_rThat.m_pszFreeValue; 285 if (a_rThat.m_pszFreeValue != NULL) 286 { 287 m_pszFreeValue = (char *)RTMemDup(m_pszValue, m_cbValue + 1); 288 if (!m_pszFreeValue) 289 { 290 RTMsgError("Out of memory copying '%s'", m_pszValue); 291 throw std::bad_alloc(); 292 } 293 } 294 return *this; 295 } 296 }; 297 256 298 RTEXITCODE handleCreateMedium(HandlerArg *a) 257 299 { 258 class MediumProperty259 {260 public:261 const char *m_pszKey;262 const char *m_pszValue; /**< Can be binary too. */263 size_t m_cbValue;264 char *m_pszFreeValue;265 MediumProperty() : m_pszKey(NULL), m_pszValue(NULL), m_cbValue(0), m_pszFreeValue(NULL) { }266 MediumProperty(MediumProperty const &a_rThat)267 : m_pszKey(a_rThat.m_pszKey)268 , m_pszValue(a_rThat.m_pszValue)269 , m_cbValue(a_rThat.m_cbValue)270 , m_pszFreeValue(NULL)271 {272 Assert(a_rThat.m_pszFreeValue == NULL); /* not expected here! */273 }274 ~MediumProperty()275 {276 RTMemFree(m_pszFreeValue);277 m_pszFreeValue = NULL;278 }279 280 private:281 MediumProperty &operator=(MediumProperty const &a_rThat)282 {283 m_pszKey = a_rThat.m_pszKey;284 m_pszValue = a_rThat.m_pszValue;285 m_cbValue = a_rThat.m_cbValue;286 m_pszFreeValue = a_rThat.m_pszFreeValue;287 if (a_rThat.m_pszFreeValue != NULL)288 {289 m_pszFreeValue = (char *)RTMemAlloc(m_cbValue + 1);290 if (m_pszFreeValue)291 {292 memcpy(m_pszFreeValue, m_pszValue, m_cbValue + 1);293 m_pszValue = m_pszFreeValue;294 }295 else296 RTMsgError("Out of memory copying '%s'", m_pszValue);297 }298 return *this;299 }300 };301 300 std::list<MediumProperty> lstProperties; 302 301
Note:
See TracChangeset
for help on using the changeset viewer.