Original Post
Hello
Im trying to make a template function that will make a new object and return an hresult based on success or failure. (I want to try and do this without overloading new)
can anyone fix this?... thanks
::: Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile [edited by - alfmga on December 16, 2002 6:06:00 PM]
template<class type>
inline HRESULT t_s_new(type *p)
{
if((p = new type) == NULL)
return E_OUTOFMEMORY;
return S_OK;
}
// Macros for creating and deleteing new stuff.
#define s_new(type, obj) t_s_new<type>(obj)
#define s_delete(obj) if(obj){delete obj; obj = null;}
//now when I create I do the following it gives me an access violation
int *i = NULL;
s_new(int, i);
*i = 5;
s_delete(i);
::: Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile [edited by - alfmga on December 16, 2002 6:06:00 PM]