A
Amit_Basnak
Dear Friend which one is the better way of assigning memory and
releasing it
//WF_STRUCT_WORKUNIT is a Structure
WF_STRUCT_WORKUNIT *p_str_Workunit = (WF_STRUCT_WORKUNIT *) new char
[ sizeof(WF_STRUCT_WORKUNIT) ];
if (p_str_Workunit!)
{
TError error( TError ( CString( __FILE__ )
,__LINE__
,TRM_NO_MEMORY
,0
,CString("") ));
throw new tException(error);
}
conObj.CopyToDceWF_STRUCT_WORKUNIT(p_str_Workunit,pStrWorkUnit); //
function call
OR
WF_STRUCT_WORKUNIT *p_str_Workunit = (WF_STRUCT_WORKUNIT
*)malloc(sizeof(WF_STRUCT_WORKUNIT));
memset(p_str_Workunit,'\0',sizeof(WF_STRUCT_WORKUNIT));
conObj.CopyToDceWF_STRUCT_WORKUNIT(p_str_Workunit,pStrWorkUnit); //
function call
Thanks
Amit
releasing it
//WF_STRUCT_WORKUNIT is a Structure
WF_STRUCT_WORKUNIT *p_str_Workunit = (WF_STRUCT_WORKUNIT *) new char
[ sizeof(WF_STRUCT_WORKUNIT) ];
if (p_str_Workunit!)
{
TError error( TError ( CString( __FILE__ )
,__LINE__
,TRM_NO_MEMORY
,0
,CString("") ));
throw new tException(error);
}
conObj.CopyToDceWF_STRUCT_WORKUNIT(p_str_Workunit,pStrWorkUnit); //
function call
OR
WF_STRUCT_WORKUNIT *p_str_Workunit = (WF_STRUCT_WORKUNIT
*)malloc(sizeof(WF_STRUCT_WORKUNIT));
memset(p_str_Workunit,'\0',sizeof(WF_STRUCT_WORKUNIT));
conObj.CopyToDceWF_STRUCT_WORKUNIT(p_str_Workunit,pStrWorkUnit); //
function call
Thanks
Amit