made_of_asp
Oct 7th, 2002, 08:32 AM
Is this function leaking memory?
char** VirtualSplitString(char* pString, char sep, int& uBound)
{
unsigned long s = 0; unsigned long i = 0;
char** pArray = (char**)calloc(0, sizeof(char));
//allocate empty storage
//the first array
pArray[0] = (char*)calloc(1024, sizeof(char));
//separate an array...
while(*pString)
{
//go through the string, find position
if(*pString == sep)
{
i++;
s = 0; //current position
//allocate space for new input
pArray[i] = (char*)calloc(1024, sizeof(char));
}
else
{
//get the current character and set it
pArray[i][s] = *pString;
//increase character position
s++;
}
//increase string position
pString++;
}
uBound = ++i;
//return the pArray data type
return pArray;
};
thanks for any help...
char** VirtualSplitString(char* pString, char sep, int& uBound)
{
unsigned long s = 0; unsigned long i = 0;
char** pArray = (char**)calloc(0, sizeof(char));
//allocate empty storage
//the first array
pArray[0] = (char*)calloc(1024, sizeof(char));
//separate an array...
while(*pString)
{
//go through the string, find position
if(*pString == sep)
{
i++;
s = 0; //current position
//allocate space for new input
pArray[i] = (char*)calloc(1024, sizeof(char));
}
else
{
//get the current character and set it
pArray[i][s] = *pString;
//increase character position
s++;
}
//increase string position
pString++;
}
uBound = ++i;
//return the pArray data type
return pArray;
};
thanks for any help...