From e6f8da256f3ef5a1330bff893ced741a47c11ab3 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 15 Jun 2023 16:22:48 +0200 Subject: [PATCH] perfect SetDeviceName --- LEGO1/mxvideoparam.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/LEGO1/mxvideoparam.cpp b/LEGO1/mxvideoparam.cpp index 8e33560b..19dbad96 100644 --- a/LEGO1/mxvideoparam.cpp +++ b/LEGO1/mxvideoparam.cpp @@ -30,20 +30,21 @@ MxVideoParam &MxVideoParam::operator=(const MxVideoParam &other) return *this; } -// TODO: this doesn't match exactly, something weird with the conditional on id void MxVideoParam::SetDeviceName(char *id) { if (this->m_deviceId != 0) free(this->m_deviceId); - if (id == 0) - { - this->m_deviceId = 0; - } - else + if (id != 0) { this->m_deviceId = (char *)malloc(strlen(id) + 1); - strcpy(this->m_deviceId, id); + + if (this->m_deviceId != 0) { + strcpy(this->m_deviceId, id); + } + } + else { + this->m_deviceId = 0; } }