void *n64_malloc(size_t size_to_alloc) { if (0 == kv_set) { kv_set = new_kv(1024); } int adjusted_size = size_to_alloc; if (size_to_alloc < 8) { adjusted_size = 8; } else if (size_to_alloc % 8 != 0) { adjusted_size += (8 - (size_to_alloc % 8)); } void *buf = malloc(adjusted_size); if (0 != buf) { allocated_bytes += adjusted_size; } // map address to size and store somewhere mapadd(kv_set, ((uint32_t)&buf)&0x0FFFFFFF, adjusted_size); return buf; }
void InterventionsContainer::ChangeProperty( const char * property, const char * new_value ) { /* LOG_DEBUG_F( "ChangeProperty: property = %s, new_value = %s\n", property, new_value ); if( strlen( property ) == 0 ) { throw IllegalOperationException( __FILE__, __LINE__, __FUNCTION__, "ChangeProperty called with empty property string." ); } if( strlen( new_value ) == 0 ) { throw IllegalOperationException( __FILE__, __LINE__, __FUNCTION__, "ChangeProperty called with empty value string." ); } */ // Get parent property (remove need for casts) IPKeyValueContainer* pProps = parent->GetEventContext()->GetProperties(); // Check that property exists, except Age_Bins which are special case. We bootstrap individuals into age_bins at t=1, // with no prior existing age bin property. IPKey key( property ); if( ( std::string( property ) != "Age_Bin" ) && !pProps->Contains( key ) ) { throw BadMapKeyException( __FILE__, __LINE__, __FUNCTION__, "properties", property ); } IPKeyValue new_kv( property, new_value ); if( !pProps->Contains( new_kv ) ) { IPKeyValue old_kv = pProps->Get( key ); LOG_DEBUG_F( "Moving individual (%lu) property %s from %s to %s\n", parent->GetSuid().data, property, old_kv.GetValueAsString().c_str(), new_value ); parent->UpdateGroupPopulation(-1.0f); pProps->Set( new_kv ); parent->UpdateGroupMembership(); parent->UpdateGroupPopulation(1.0f); parent->SetPropertyReportString(""); //broadcast that the individual changed properties IIndividualEventBroadcaster* broadcaster = parent->GetEventContext()->GetNodeEventContext()->GetIndividualEventBroadcaster(); LOG_DEBUG_F( "Individual %d changed property, broadcasting PropertyChange \n", parent->GetSuid().data ); broadcaster->TriggerObservers( parent->GetEventContext(), EventTrigger::PropertyChange ); } }