library/src/network/email/BP-EmailSMTP.cc
// destroys a message structure (null pointer after destroyed to prevent reuse)
destroys a message structure (null pointer after destroyed to prevent reuse)
destroys a message structure ( null pointer after destroyed to prevent reuse )
BP_ERROR_T BP_DestroySMTPMessage(P_BP_EMAIL_SMTP_MESSAGE message)
{
	if(!message)
		return ERR_FAILURE;
	size_t n = 0;
	if(message->recipient_cnt)
	for(n=0; n < message->recipient_cnt; n++)
	{
		if(message->recipients[n])
			bpfree(message->recipients[n]);
		message->recipients[n] = NULL;
	}
	if(message->recipients)
		bpfree(message->recipients);
	if(message->header_cnt)
	for(n=0; n < message->header_cnt; n++)
	{
		if(message->headers[n])
			bpfree(message->headers[n]);
		message->headers[n] = NULL;
	}
	if(message->headers)
		bpfree(message->headers);
	if(message->message_line_cnt)
	for(n=0; n < message->message_line_cnt; n++)
	{
		if(message->message_body[n])
			bpfree(message->message_body[n]);
		message->message_body[n] = NULL;
	}
	if(message->message_body)
		bpfree(message->message_body);
	bpfree(message);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DestroySMTPMessage ( P_BP_EMAIL_SMTP_MESSAGE message ) { if ( ! message ) return ERR_FAILURE ; size_t n = 0 ; if ( message -> recipient_cnt ) for ( n = 0 ; n < message -> recipient_cnt ; n ++ ) { if ( message -> recipients [ n ] ) bpfree ( message -> recipients [ n ] ) ; message -> recipients [ n ] = NULL ; } if ( message -> recipients ) bpfree ( message -> recipients ) ; if ( message -> header_cnt ) for ( n = 0 ; n < message -> header_cnt ; n ++ ) { if ( message -> headers [ n ] ) bpfree ( message -> headers [ n ] ) ; message -> headers [ n ] = NULL ; } if ( message -> headers ) bpfree ( message -> headers ) ; if ( message -> message_line_cnt ) for ( n = 0 ; n < message -> message_line_cnt ; n ++ ) { if ( message -> message_body [ n ] ) bpfree ( message -> message_body [ n ] ) ; message -> message_body [ n ] = NULL ; } if ( message -> message_body ) bpfree ( message -> message_body ) ; bpfree ( message ) ; return ERR_SUCCESS ; }
destroys a message structure (null pointer after destroyed to prevent reuse)
destroys a message structure ( null pointer after destroyed to prevent reuse )
// check to see that we have a message // generic loop iterator used to process unallocation // list of recipients // check for a pointer and bpfree // zero out pointer // set message recipients // bpfree list of headers // check for a pointer and bpfree // zero out pointer // bpfree actual headers array // bpfree list of message lines // check for a pointer and bpfree // zero out pointer // bpfree actual message body array // finally, destroy the message structure // return indicating success