예제 #1
0
	// DebugAllocator::Config::configure_allocator
	IAllocator * DebugAllocator::Config::configure_allocator( IAllocator * i_new_allocator ) const
	{
		DebugAllocator * allocator;
		if( i_new_allocator != nullptr )
			allocator = static_cast< DebugAllocator * >( i_new_allocator );
		else
			allocator = MEMO_NEW( DebugAllocator );

		DecoratorAllocator::Config::configure_allocator( allocator );

		allocator->set_config( *this );

		return allocator;
	}
예제 #2
0
파일: load.c 프로젝트: scorpion007/ruby
static int
register_init_ext(st_data_t *key, st_data_t *value, st_data_t init, int existing)
{
    const char *name = (char *)*key;
    if (existing) {
	/* already registered */
	rb_warn("%s is already registered", name);
    }
    else {
	*value = (st_data_t)MEMO_NEW(0, 0, init);
	*key = (st_data_t)ruby_strdup(name);
    }
    return ST_CONTINUE;
}
예제 #3
0
	void MemoryManager::Config::load( serialization::IConfigReader & i_config_reader )
	{
		while( i_config_reader.read_next_property() )
		{
			if( i_config_reader.try_recognize_property( "context" ) )
			{
				const char * context_name = i_config_reader.curr_property_vakue_as_string();

				ContextConfig * new_context = MEMO_NEW( ContextConfig, context_name );

				m_root_context.add_inner_context( new_context );

				i_config_reader.tab();

				new_context->load( i_config_reader );

				i_config_reader.untab();
			}
			else if( i_config_reader.try_recognize_property( "global_allocator" ) )
			{
				const char * allocator_name = i_config_reader.curr_property_vakue_as_string();

				IAllocator::Config * global_allocator = MemoryManager::get_instance().allocator_config_factor().create_allocator_config( allocator_name );
				if( global_allocator == nullptr )
				{
					i_config_reader.output_message( serialization::eWrongContent );
					break;
				}

				m_root_context.set_allocator_config( global_allocator );

				i_config_reader.tab();

				global_allocator->load( i_config_reader );

				i_config_reader.untab();
			}
			else
			{
				i_config_reader.output_message( serialization::eUnrecognizedProperty );
				break;
			}
		}
	}