Browse Source

centralize imap_cmd disposal

wip/maildir-uid-dupes-test
Oswald Buddenhagen 14 years ago
parent
commit
886cd03e37
  1. 29
      src/drv_imap.c

29
src/drv_imap.c

@ -204,6 +204,15 @@ new_imap_cmd( int size )
cmdp->gen.callback = cb; \ cmdp->gen.callback = cb; \
cmdp->gen.callback_aux = aux; cmdp->gen.callback_aux = aux;
static void
done_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd, int response )
{
cmd->param.done( ctx, cmd, response );
free( cmd->param.data );
free( cmd->cmd );
free( cmd );
}
static struct imap_cmd * static struct imap_cmd *
v_submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd, v_submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd,
const char *fmt, va_list ap ) const char *fmt, va_list ap )
@ -264,10 +273,7 @@ v_submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd,
bail: bail:
imap_invoke_bad_callback( ctx ); imap_invoke_bad_callback( ctx );
bail2: bail2:
cmd->param.done( ctx, cmd, RESP_CANCEL ); done_imap_cmd( ctx, cmd, RESP_CANCEL );
free( cmd->param.data );
free( cmd->cmd );
free( cmd );
return NULL; return NULL;
} }
@ -291,10 +297,7 @@ cancel_submitted_imap_cmds( imap_store_t *ctx )
while ((cmd = ctx->in_progress)) { while ((cmd = ctx->in_progress)) {
ctx->in_progress = cmd->next; ctx->in_progress = cmd->next;
/* don't update num_in_progress and in_progress_append - store is dead */ /* don't update num_in_progress and in_progress_append - store is dead */
cmd->param.done( ctx, cmd, RESP_CANCEL ); done_imap_cmd( ctx, cmd, RESP_CANCEL );
free( cmd->param.data );
free( cmd->cmd );
free( cmd );
} }
} }
@ -901,12 +904,9 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
imap_ref( ctx ); imap_ref( ctx );
if (resp == RESP_CANCEL) if (resp == RESP_CANCEL)
imap_invoke_bad_callback( ctx ); imap_invoke_bad_callback( ctx );
cmdp->param.done( ctx, cmdp, resp ); done_imap_cmd( ctx, cmdp, resp );
if (imap_deref( ctx )) if (imap_deref( ctx ))
resp = RESP_CANCEL; resp = RESP_CANCEL;
free( cmdp->param.data );
free( cmdp->cmd );
free( cmdp );
if (resp == RESP_CANCEL || !tcmd || tcmd == cmdp) if (resp == RESP_CANCEL || !tcmd || tcmd == cmdp)
return resp; return resp;
} }
@ -922,10 +922,7 @@ get_cmd_result_p2( imap_store_t *ctx, struct imap_cmd *cmd, int response )
struct imap_cmd *ocmd = cmdp->orig_cmd; struct imap_cmd *ocmd = cmdp->orig_cmd;
if (response != RESP_OK) { if (response != RESP_OK) {
ocmd->param.done( ctx, ocmd, response ); done_imap_cmd( ctx, ocmd, response );
free( ocmd->param.data );
free( ocmd->cmd );
free( ocmd );
} else { } else {
ctx->uidnext = 0; ctx->uidnext = 0;
ocmd->param.create = 0; ocmd->param.create = 0;

Loading…
Cancel
Save