Segmentation Fault: new char[12]
atharaken@my-deja.com
atharaken@my-deja.com
Tue Dec 7 12:11:00 GMT 1999
This is a snippet of some code I am using. I get a Segmentation Fault
in _smalloc (malloc). It works sometimes and when a large number of
users are accessing it gives a segmentation fault.
It happens at the line:
_string = new char [_capacity];
I call this using _Init(12);
This is a protected class.
/* BEGIN CODE HERE */
bool MyClass::_Init (long size)
{
_capacity = size;
_string = new char [_capacity]; //Get Segmentation Fault at _smalloc
if (!_string) {
_capacity = _size = 0L;
return false;
}
_size = 0;
_string[0] = '\0';
return true;
}
/*END CODE HERE */
Machine: i386
OS: Solaris 7
GCC 2.95 (Release)
Any help is appreciated
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Gcc-help
mailing list