Security software was a topic in the June 2009 issue of Consumer Reports.
The top security software was Eset Smart Security. It costs a little bit more than other software but it offered the best possible virus detection. It's good if you have a computer user who clicks on suspicious email links or downloads files from unfamiliar sites.
McAfee Internet Security is next on the list. It offers good performance and the most features.
Symantec Norton Internet Security was the third recommendation. It was the best at finding badware. It also gives you information on possible threats.
No computer should go without security software. If someone hacks into your computer, personal information could be taken which could lead to identity theft. A hacker could also delete your files, take control of your computer, or render your computer useless. Hackers these days are very sophisticated, so installing good, trustworthy security software is an absolute must.
Consumer Reports Back Issues
Friday, July 24, 2009
Thursday, July 9, 2009
Vector of pointers crashes on delete
I have a java gui which calls a C++ dll which in turn calls another C++ dll. Both dlls are built using Microsoft Visual C++ 6.0;
Both dlls contain functions which take in 4 vectors. The first dll function calls the second dll function.
The first 2 vectors are source parameters and the last 2 are result vectors. All vectors contain the same number elements.
The function call in the first dll looks something like this:
convert(std::vector& firstVector, std::vector& secondVector, std::vector& thirdVector, std::vector& fourthVector)
{
thirdVector.reserve(10);
fourthVector.reserve(10);
C2DLL* c2dll = new c2dll();
c2dll->convert(firstVector, secondVector, thirdVector, fourthVector);
.
.
.
.
.
.
.
for(int i = 0; i < 10; i++)
{
delete firstVector[i];
}
firstVector.clear();
for(int i = 0; i < 10; i++)
{
delete secondVector[i];
}
secondVector.clear();
for(int i = 0; i < 10; i++)
{
delete thirdVector[i];
}
thirdVector.clear();
for(int i = 0; i < 10; i++)
{
delete fourthVector[i];
}
fourthVector.clear();
}
void C2DLL::convert(std::vector& firstVector, std::vector& secondVector, std::vector& thirdVector, std::vector& fourthVector)
{
for(int i = 0; i < 10; i++)
{
thirdVector.push_back(new Class2()); /// Class2 is a subclass of Class1
fourthVector.push_back(new ClassA());
}
}
Everything was running great until I would get to deleting each element of the fourthVector. The application would crash. For the life of me I could not figure out why. I finally did some Google searching and figured out it was the compiler settings.
Each dll needs to be built with the /MD option. To set this, go to the project settings, C/C++ tab, Code Generation Category. Select Debug Multithreaded DLL.
Apparently this allocates the memory used in each dll on the local heap. Before changing this setting, I was using Debug Mutithreaded. Since the memory for the fourth vector was allocated in the second C++ dll, the memory was not on the local heap for the first dll, which was where the memory was being deallocated.
C++ Memory, what a pain in the butt.
More C++
Both dlls contain functions which take in 4 vectors. The first dll function calls the second dll function.
The first 2 vectors are source parameters and the last 2 are result vectors. All vectors contain the same number elements.
The function call in the first dll looks something like this:
convert(std::vector
{
thirdVector.reserve(10);
fourthVector.reserve(10);
C2DLL* c2dll = new c2dll();
c2dll->convert(firstVector, secondVector, thirdVector, fourthVector);
.
.
.
.
.
.
.
for(int i = 0; i < 10; i++)
{
delete firstVector[i];
}
firstVector.clear();
for(int i = 0; i < 10; i++)
{
delete secondVector[i];
}
secondVector.clear();
for(int i = 0; i < 10; i++)
{
delete thirdVector[i];
}
thirdVector.clear();
for(int i = 0; i < 10; i++)
{
delete fourthVector[i];
}
fourthVector.clear();
}
void C2DLL::convert(std::vector
{
for(int i = 0; i < 10; i++)
{
thirdVector.push_back(new Class2()); /// Class2 is a subclass of Class1
fourthVector.push_back(new ClassA());
}
}
Everything was running great until I would get to deleting each element of the fourthVector. The application would crash. For the life of me I could not figure out why. I finally did some Google searching and figured out it was the compiler settings.
Each dll needs to be built with the /MD option. To set this, go to the project settings, C/C++ tab, Code Generation Category. Select Debug Multithreaded DLL.
Apparently this allocates the memory used in each dll on the local heap. Before changing this setting, I was using Debug Mutithreaded. Since the memory for the fourth vector was allocated in the second C++ dll, the memory was not on the local heap for the first dll, which was where the memory was being deallocated.
C++ Memory, what a pain in the butt.
More C++
Subscribe to:
Posts (Atom)