I am a little unclear on what is happening here and if it's even necessary.

ICOMInterface** pICOMInterface = new ICOMInterface*[reserve];

for(SIZE_T i = 0; i < required; i++)
    pICOMInterface[i] = new ImplementingClass;
for(SIZE_T i = (reserve-1); i >= required; i--)
    delete pICOMInterface[i];

I'm trying to get a set of a contained implementing class without knowing the size. I want to declare its maximum size and then delete or free the unused ones/memory after....

Have you considered using STL containers instead? Such as vector<ICOMInterface*> or list<ICOMInterface*> for example.

I am making a custom container and allocator..... I am well aware of STL, yes! Still hoping to hear some thoughts on this would like to know a little more about how this is breaking down behind the scenes when I make the call. I mean If I new IInterface[8] all I have in my 64bit app is 8 64bit pointers.... they are not pointing to anything functional. So that said what do I do with the pointers when I don't care about them anymore just forget??? I nulled them once results where not so good but that could have been me overwriting something. It broke my program at any rate......

Just curious about the two lines of code that are rem'd if I want to shrink my reserve on the memory do I just forget that I ever called to use it?? (I know it's messy)

HRESULT MemmoryManager::Query(IBaseModule*** ppIModule, SIZE_T* p_num_modules, NAME_SEMANTIC* name)
{
	HRESULT hr = S_OK;;

	if(!name)
		return S_FALSE;

	UINT num_modules = 0;
	if(!name->semantic)
	{
		*ppIModule = new IBaseModule*[reserved];
		for(SIZE_T i = 0; i < reserved; i++)
		{
			if((wcscmp(name->name,Index[i].name) == 0))
			{
				if(SUCCEEDED(pIModulesIndexed[i]->QueryInterface(
							__uuidof(ppIModule[0][num_modules]), 
							(void**)&ppIModule[0][num_modules]) ) )
				num_modules++;
			}
		}
//		for(SIZE_T i = (reserved-1); i >= num_modules; i--)
//			ppIModule[i] = NULL;
	}
	else
	{
		for(SIZE_T i = 0; i < reserved; i++)
		{
			if((wcscmp(name[i].name,Index[i].name) == 0) && (name[i].semantic,Index[i].semantic))
			{
				if(SUCCEEDED(pIModulesIndexed[i]->QueryInterface(
							__uuidof(ppIModule[0][0]), 
							(void**)&ppIModule[0][0]) ) )
				num_modules = 1;
				break;
			}
		}
	}

	*p_num_modules = num_modules;

	return hr;
}

I learned that after my original post, although that brought up the question of why is DX COM but there is no requisite to call CoCreateInstance() in the implementing API! That is however another question and I had only added that in the case that it mattered. The question still holds on other abstract interfaces. If you have a non COM interface whose prerequisite is to have a virtual dtor and a new is called on the interface not an implementing class what happens in the above scenario??? The virtual dtor will..... and the remaining pointer is just forgotten?? I apologize if my question lacks somehow... o~o

Thanks again! o-o

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.