I don't know what's going on here...but I always seem to get 2 leaks of 40bytes each consisting of FF FF FF FF.... Even with all the code commented out, I still seem to get these leaks. I'm running Visual Studio on Vista SP1, so perhaps a combatibility issue? Or maybe I'm just forgetting my DMA from the years class. Here's the code:

#include <iostream>
using namespace std;
#include "funcs.h"
// Turning on the heap checker

bool HashMake(int *&iHash, int iSize)
{
	bool bReturn = true;
	if (iSize >= 1)
	{
		HashFree(iHash, iSize);
		iHash = new (nothrow) int[iSize];
		for (int i = 0; i < iSize; i++)
			iHash[i] = -1;
	}
	else
		bReturn = false;

	return bReturn;
}

void HashFree(int *&iHash, int iSize)
{
	delete [] iHash;
	iHash = 0;
	return;
}

void TestCode()
{
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	/*int const SIZE = 10;
	int * iHash(NULL);
	HashMake(iHash, SIZE);
	for (int i = 0; i < SIZE; i++)
		cout << iHash[i] << endl; */
	cin.get();
//	HashFree(iHash, SIZE);
}

all that is called in main.cpp is the testcode() function. I commented out any time dma is used (in testcode() ) and the stupid memory leaks still show up. I'm getting frustrated!! Any help would be appreciated!

Hmmm ok update. The leaks are being found before I even start the program, like just as I hit F5 to build it they appear. If I purposely break the code and get rid of the deletes, all 10 of the leaks append to the 2 leaks. What could cause this :S

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.