I have a small function as below:
token has been new'ed in this function and getting insert into the tokens list, which is a pointer list. If I will delete token will it be a problem? If I have to delete how to delete this token?
FYI,
typedef struct TOKEN
{
char * Name; /* Name of token */
int Type; /* Type of token */
/* 0 - String */
/* 1 - Enumeration */
/* 2 - Numeric floating */
/* 3 - Numeric integer */
/* 4 - Timeband */
/* 5 - Date */
/* 6 - Numeric floating / sBP */
/* 7 - Numeric floating / 100 */
char * EType; /* Enumeration string type (if applicable) */
int Size; /* Size of the variable pointed to by this token */
int Offset; /* Offset of variable into structure */
}Token ;
Thanks in advance.
Code:
int dmgCreateFilter( DmgString ListOfParam[NUMBERPARAMMAX], sTRADE_FILTER& aFilter, int aMode ) { try { DmgPtrList<Token> tokens; for ( int i=0; i<NUMBERPARAMMAX/2; ++i ) { if ( ListOfParam[2*i].IsBlank() != sYES ) { Token* token = new Token( ListOfParam[2*i], ListOfParam[2*i+1] ); tokens.insert( token ); } } DmgFilter filter( &aFilter ); filter.ReInit(); filter.Create( tokens ); if ( aMode == 01 ) { filter.DoSTDAction( NULL, sACT_SAVE, 00 ); } return sSUCCESS; } catch( DmgException& listEx ) { listEx.ReThrowGpo(" Exception in dmgCreateFilter ", sSERIOUS ); } catch ( ... ) { DmgException::ThrowGpo( "dmgCreateFilter::dmgCreateFilter() : Unknown Exception", sSERIOUS ); } }
FYI,
typedef struct TOKEN
{
char * Name; /* Name of token */
int Type; /* Type of token */
/* 0 - String */
/* 1 - Enumeration */
/* 2 - Numeric floating */
/* 3 - Numeric integer */
/* 4 - Timeband */
/* 5 - Date */
/* 6 - Numeric floating / sBP */
/* 7 - Numeric floating / 100 */
char * EType; /* Enumeration string type (if applicable) */
int Size; /* Size of the variable pointed to by this token */
int Offset; /* Offset of variable into structure */
}Token ;
Thanks in advance.
Comment