Refactor free of command/transaction code to function
This commit is contained in:
36
asyncqueue.c
36
asyncqueue.c
@ -90,6 +90,22 @@ static const char *state_name(AsyncState the_state)
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the command and transaction structures and their contents
|
||||
*/
|
||||
static void free_command(pAQ_Cmd myCmd)
|
||||
{
|
||||
free(myCmd->tran->out_buf);
|
||||
free(myCmd->tran->inp_buf);
|
||||
if (myCmd->tran->proto_private)
|
||||
if (myCmd->tran->kill_private)
|
||||
myCmd->tran->kill_private(myCmd->tran);
|
||||
else
|
||||
free(myCmd->tran->proto_private);
|
||||
free(myCmd->tran);
|
||||
free(myCmd);
|
||||
}
|
||||
|
||||
/* ---------------------------- Local ------------------------------------
|
||||
CreateSocketAdress stolen from Tcl. Thanks to John Ousterhout
|
||||
*/
|
||||
@ -165,15 +181,7 @@ static void AQ_Purge(pAsyncQueue self)
|
||||
self->command_head = myCmd->next;
|
||||
} else
|
||||
self->command_head = self->command_tail = NULL;
|
||||
free(myCmd->tran->out_buf);
|
||||
free(myCmd->tran->inp_buf);
|
||||
if (myCmd->tran->proto_private)
|
||||
if (myCmd->tran->kill_private)
|
||||
myCmd->tran->kill_private(myCmd->tran);
|
||||
else
|
||||
free(myCmd->tran->proto_private);
|
||||
free(myCmd->tran);
|
||||
free(myCmd);
|
||||
free_command(myCmd);
|
||||
myCmd = self->command_head;
|
||||
}
|
||||
}
|
||||
@ -458,15 +466,7 @@ static int PopCommand(pAsyncQueue self)
|
||||
StartCommand(self);
|
||||
} else
|
||||
self->command_head = self->command_tail = NULL;
|
||||
free(myCmd->tran->out_buf);
|
||||
free(myCmd->tran->inp_buf);
|
||||
if (myCmd->tran->proto_private)
|
||||
if (myCmd->tran->kill_private)
|
||||
myCmd->tran->kill_private(myCmd->tran);
|
||||
else
|
||||
free(myCmd->tran->proto_private);
|
||||
free(myCmd->tran);
|
||||
free(myCmd);
|
||||
free_command(myCmd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user