Ok, first, a bit of background
The software I'm working on now has a web front end, but enters data and queries data from a Remedy server.
Now, all of the functions to submit and query work flawlessly, however, in my first version of the ActiveX DLL I had a memory leak... The Inetinfo process on our production box would consume 300MB of memory and die.
I found that the problem was My original function for converting BSTR to Char was flawed in that I did not deallocate memory that I allocated.
Now here's my second version, I want to make sure it looks Kosher before I place it in production.
char* CMARS::ConvertBSTRtoCHAR(BSTR BSTRString)
{
_bstr_t *tempbstr = new _bstr_t;
tempbstr->Assign(BSTRString);
char *string = 0;
string = new char[tempbstr->length()+1];
strcpy(string,tempbstr->operator const char *());
delete tempbstr;
tempbstr=0;
return string;
}
I store the returned character string pointer in a linked list, and when the function that uses the convertBSTRtoCHAR is done, it deallocates all the memory. So far it looks good.
So question is: Does this function look good? (for taking a BSTR variable and converting to a character pointer)
And, is there any software I can use to determine if there is still a memory leak?
Thanks,
Mike
The software I'm working on now has a web front end, but enters data and queries data from a Remedy server.
Now, all of the functions to submit and query work flawlessly, however, in my first version of the ActiveX DLL I had a memory leak... The Inetinfo process on our production box would consume 300MB of memory and die.
I found that the problem was My original function for converting BSTR to Char was flawed in that I did not deallocate memory that I allocated.
Now here's my second version, I want to make sure it looks Kosher before I place it in production.
char* CMARS::ConvertBSTRtoCHAR(BSTR BSTRString)
{
_bstr_t *tempbstr = new _bstr_t;
tempbstr->Assign(BSTRString);
char *string = 0;
string = new char[tempbstr->length()+1];
strcpy(string,tempbstr->operator const char *());
delete tempbstr;
tempbstr=0;
return string;
}
I store the returned character string pointer in a linked list, and when the function that uses the convertBSTRtoCHAR is done, it deallocates all the memory. So far it looks good.
So question is: Does this function look good? (for taking a BSTR variable and converting to a character pointer)
And, is there any software I can use to determine if there is still a memory leak?
Thanks,
Mike