// assign this object the oid, set to invalid if copy fails void Oid::init_value(const SmiLPOID srcOid, size_t len) { // allocate some memory for the oid ACE_NEW(smival.value.oid.ptr, SmiUINT32[ len]); size_t byte_counter; OidCopy( srcOid, (SmiLPOID) &smival.value.oid, byte_counter); }
//=============[Oid::Oid( const Oid &oid) ]================================ // constructor using another oid object // // do an oid copy using the oid object passed in Oid::Oid ( const Oid &oid) : SnmpSyntax (oid) { set_null(); // allocate some memory for the oid // in this case the size to allocate is the same // size as the source oid if (oid.smival.value.oid.len) { ACE_NEW(smival.value.oid.ptr, SmiUINT32[ oid.smival.value.oid.len]); size_t byte_counter; OidCopy( (SmiLPOID) &(oid.smival.value.oid),(SmiLPOID) &smival.value.oid, byte_counter); } }
//=============[Oid:: operator = const Oid &oid ]========================== // assignment to another oid object overloaded // // free the existing oid // create a new one from the object passed in Oid& Oid::operator=(const Oid &oid) { if (this == &oid) return *this; // protect against assignment from self delete_oid_ptr(); // check for zero len on source if (oid.smival.value.oid.len == 0) return *this; // allocate some memory for the oid smival.value.oid.ptr = (SmiLPUINT32) new unsigned long[oid.smival.value.oid.len]; if (smival.value.oid.ptr) OidCopy((SmiLPOID)&(oid.smival.value.oid), (SmiLPOID)&smival.value.oid); return *this; }
//=============[Oid::Oid(const Oid &oid) ]================================ // constructor using another oid object // // do an oid copy using the oid object passed in Oid::Oid(const Oid &oid) : iv_str(0), iv_part_str(0), m_changed(true) { smival.syntax = sNMP_SYNTAX_OID; smival.value.oid.len = 0; smival.value.oid.ptr = 0; // allocate some memory for the oid // in this case the size to allocate is the same size as the source oid if (oid.smival.value.oid.len) { smival.value.oid.ptr = (SmiLPUINT32) new unsigned long[oid.smival.value.oid.len]; if (smival.value.oid.ptr) OidCopy((SmiLPOID)&(oid.smival.value.oid), (SmiLPOID)&smival.value.oid); } }