summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-22 15:48:16 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-22 15:48:16 +0000
commit75eddb1ebbae7795daa54bc849fd66092511aa16 (patch)
treef9e7d2a79a0ff2d4988f802aac8ed0ac34cff5de
parent45d8248efb7996d29667ced8bd652b18d25cb9ed (diff)
downloadlibssh-75eddb1ebbae7795daa54bc849fd66092511aa16.tar.gz
libssh-75eddb1ebbae7795daa54bc849fd66092511aa16.tar.xz
libssh-75eddb1ebbae7795daa54bc849fd66092511aa16.zip
Improve request_queue_(new,free).
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@581 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r--libssh/sftp.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/libssh/sftp.c b/libssh/sftp.c
index d26e722..f4ae481 100644
--- a/libssh/sftp.c
+++ b/libssh/sftp.c
@@ -480,22 +480,27 @@ int sftp_init(SFTP_SESSION *sftp) {
return 0;
}
-static REQUEST_QUEUE *request_queue_new(SFTP_MESSAGE *msg){
- REQUEST_QUEUE *queue;
+static REQUEST_QUEUE *request_queue_new(SFTP_MESSAGE *msg) {
+ REQUEST_QUEUE *queue = NULL;
- queue = malloc(sizeof(REQUEST_QUEUE));
- if (queue == NULL) {
- return NULL;
- }
+ queue = malloc(sizeof(REQUEST_QUEUE));
+ if (queue == NULL) {
+ return NULL;
+ }
+ ZERO_STRUCTP(queue);
- memset(queue,0,sizeof(REQUEST_QUEUE));
- queue->message=msg;
- return queue;
+ queue->message = msg;
+
+ return queue;
}
-static void request_queue_free(REQUEST_QUEUE *queue){
- memset(queue,0,sizeof(*queue));
- free(queue);
+static void request_queue_free(REQUEST_QUEUE *queue) {
+ if (queue == NULL) {
+ return;
+ }
+
+ ZERO_STRUCTP(queue);
+ SAFE_FREE(queue);
}
void sftp_enqueue(SFTP_SESSION *sftp, SFTP_MESSAGE *msg){