티스토리 뷰

카테고리 없음

테스트

DWGoon 2009. 7. 31. 14:33
int main () {


	const size_t ELEM_NUM = 10;

	cout << "Test 객체의 크기는" << sizeof(Test) << endl;
	cout << sizeof((Test *)new Test) << endl;


	// auto array
	cout << "Test arrTest[ELEM_NUM];" << endl;
	Test arrTest[ELEM_NUM];


	// allocator
	cout << endl << "Test * ptrTest = alloc.allocate(ELEM_NUM);" << endl;
	allocator alloc;
	Test * ptrTest = alloc.allocate(ELEM_NUM);
	

	// my implementation for allocation
	cout << endl << "Test * ptr = allocation(ELEM_NUM);" << endl;
	Test * ptr = allocation(ELEM_NUM);
	
	free(ptr);



	Test * it = ptrTest + ELEM_NUM;
	while (it != ptrTest) {
		alloc.destroy(--it);
	}
	alloc.deallocate(ptrTest, ELEM_NUM);

	_CrtDumpMemoryLeaks();
	
	// system("PAUSE");
	return 0;
}
댓글