diff --git a/src/mms/iso_mms/common/mms_value.c b/src/mms/iso_mms/common/mms_value.c index f38d84dd..f45cae43 100644 --- a/src/mms/iso_mms/common/mms_value.c +++ b/src/mms/iso_mms/common/mms_value.c @@ -101,10 +101,7 @@ MmsValue_newUnsignedFromBerInteger(Asn1PrimitiveValue* berInteger) bool MmsValue_equals(const MmsValue* self, const MmsValue* otherValue) { - if ((self == NULL) || (otherValue == NULL)) - return false; - - if (self->type == otherValue->type) { + if (equalType(self, otherValue)) { switch (self->type) { case MMS_ARRAY: @@ -193,13 +190,24 @@ MmsValue_equals(const MmsValue* self, const MmsValue* otherValue) return false; } +static bool +equalType(const MmsValue* self, const MmsValue* otherValue) { + if (self->type == otherValue->type || + (self->type == MMS_STRUCTURE && otherValue->type == MMS_ARRAY) || + (self->type == MMS_ARRAY && otherValue->type == MMS_STRUCTURE)) + return true; + + return false; +} + bool MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue) { if ((self == NULL) || (otherValue == NULL)) return false; - if (self->type == otherValue->type) { + if (equalType(self ,otherValue)) { + switch (self->type) { case MMS_ARRAY: @@ -228,11 +236,12 @@ MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue) return false; } + bool MmsValue_update(MmsValue* self, const MmsValue* update) { if (self && update) { - if (self->type == update->type || (self->type == MMS_STRUCTURE && update->type == MMS_ARRAY)) { + if (equalType(self, update)) { switch (self->type) { case MMS_STRUCTURE: