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>";
|
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 ------------------------------------
|
/* ---------------------------- Local ------------------------------------
|
||||||
CreateSocketAdress stolen from Tcl. Thanks to John Ousterhout
|
CreateSocketAdress stolen from Tcl. Thanks to John Ousterhout
|
||||||
*/
|
*/
|
||||||
@ -165,15 +181,7 @@ static void AQ_Purge(pAsyncQueue self)
|
|||||||
self->command_head = myCmd->next;
|
self->command_head = myCmd->next;
|
||||||
} else
|
} else
|
||||||
self->command_head = self->command_tail = NULL;
|
self->command_head = self->command_tail = NULL;
|
||||||
free(myCmd->tran->out_buf);
|
free_command(myCmd);
|
||||||
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);
|
|
||||||
myCmd = self->command_head;
|
myCmd = self->command_head;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,15 +466,7 @@ static int PopCommand(pAsyncQueue self)
|
|||||||
StartCommand(self);
|
StartCommand(self);
|
||||||
} else
|
} else
|
||||||
self->command_head = self->command_tail = NULL;
|
self->command_head = self->command_tail = NULL;
|
||||||
free(myCmd->tran->out_buf);
|
free_command(myCmd);
|
||||||
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);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user