当前位置: 首页>>代码示例>>C++>>正文


C++ FixedArray::allocate方法代码示例

本文整理汇总了C++中FixedArray::allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ FixedArray::allocate方法的具体用法?C++ FixedArray::allocate怎么用?C++ FixedArray::allocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FixedArray的用法示例。


在下文中一共展示了FixedArray::allocate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: startup

	virtual kernel::ApplicationResult startup( kernel::Params & params )
	{
#if 0
		printf( "Memory Test: \n" );
		Test * a = CREATE(Test);

		std::vector<int, GeminiAllocator<int> > int_vector;
		int_vector.push_back( 30 );
		int_vector.push_back( 16 );
		int_vector.push_back( 31 );

		typedef std::map<int, int, std::less<int>, GeminiAllocator<int> > MyMap;
		MyMap int_map;

		int_map.insert( MyMap::value_type( 30, 17 ) );
		int_map.insert( MyMap::value_type( 16, 100) );
		int_map.insert( MyMap::value_type( 300, 2 ) );

		// Test FixedArray - which should cause derived destructors
		// to be called as well as the BaseObject's destructors.
		FixedArray<BaseObject> objects;
		objects.allocate(3);
		for( size_t i = 0; i < 3; ++i )
		{
			objects[i] = CREATE(DerivedObject);
			objects[i]->type = i+4;
		}
		objects.purge();#

		// added z-modifer to satisfy Xcode, C99 addition, we'll see who doesn't support it :)
		printf( "totalAllocations: %zu, totalBytes: %zu\n", memory::allocator().total_allocations(), memory::allocator().total_bytes() );
		printf( "activeAllocations: %zu, activeBytes: %zu\n", memory::allocator().active_allocations(), memory::allocator().active_bytes() );

		DESTROY(Test, a);
		printf( "activeAllocations: %zu, activeBytes: %zu\n", memory::allocator().active_allocations(), memory::allocator().active_bytes() );
#endif

		PooledObject * p = new DerivedPoolObject();


		delete p;

		return kernel::Application_NoWindow;
	}
开发者ID:apetrone,项目名称:gemini,代码行数:44,代码来源:test_memory.cpp


注:本文中的FixedArray::allocate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。