Warning: Opinions probably included.
You have half a bazillion problems. Well, a lot, anyways.
1) INTERNET_CACHE_... is likely not fully defined at that point, so std::auto_ptr dosn't know how to delete it.
2) You're really allocating char[], not INTERNET_CACHE_..., so even if it is fully defined, it probably won't correctly delete the array.
3) std::auto_ptr uses delete. An array allocated with new char[...] must be cleaned up with
delete[]. Failure to do so will at best screw you over, at worst give you a very hard to find bug.
For arrays which don't need transfering ownership (you don't need it) I'd recommend boost::scoped_array - it has a counterpart in boost::scoped_ptr, which also prevents you from accidentally transfering ownership [
boost website].
Assuming INTERNET_CACHE_... isn't a typedef for (char *) or (char []) or similar (you should assume it's not, since they went to the bother of giving it a typedef), here is a dirty method of dealing with all this working correctly:
boost::scoped_array< char > m_Info_data;
m_Info_data.reset( new char[ 4096 ] );
INTERNET_CACHE_ENTRY_INFO* m_Info = reinterpret_cast< INTERNET_CACHE_ENTRY_INFO * >( m_Info_data.get() ); //possibly wrap up into a simple utility function instead of having it a member... e.g.:
private: INTERNET_CACHE_ENTRY_INFO* Info() { return reinterpret_cast< INTERNET_CACHE_ENTRY_INFO * >( m_Info_data.get() ); }
4) INTERNET_CACHE_ENTRY_INFO has zero encapsulation of allocation, and should be dealt with using a wrapper class that encapsulates both this and deallocation. Look up RAII (Resource Aquisition Is Initialization) for the concept which makes me say this and to expand on what I'm talking about.
Warning: Paragraph contains opinions.
Also, well formed code interfacing with well formed code shouldn't need reinterpret_cast - and well formed code needing to interface in such a manner should encapsulate these casts as much as possible. Why? Two words:
reduced mantinence. I base this on my opinion that just because it may have been well formed in the bygone days of C and it was easy to out-optimize your compiler dosn't mean it's well formed today. Times change.
-Mike