1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-03 22:13:11 +03:00

When shutting down sub-systems and closing the channel try our best

to free any memory still allocated in the state variables
This commit is contained in:
James Housley
2007-06-07 16:43:20 +00:00
parent bb32d080fa
commit b2f3582a59
5 changed files with 125 additions and 0 deletions

View File

@@ -656,6 +656,46 @@ LIBSSH2_API LIBSSH2_SFTP *libssh2_sftp_init(LIBSSH2_SESSION *session)
*/
LIBSSH2_API int libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp)
{
/*
* Make sure all memory used in the state variables are free
*/
if (sftp->partial_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->partial_packet);
}
if (sftp->open_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->open_packet);
}
if (sftp->read_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->read_packet);
}
if (sftp->readdir_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->readdir_packet);
}
if (sftp->write_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->write_packet);
}
if (sftp->fstat_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->fstat_packet);
}
if (sftp->unlink_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->unlink_packet);
}
if (sftp->rename_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->rename_packet);
}
if (sftp->mkdir_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->mkdir_packet);
}
if (sftp->rmdir_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->rmdir_packet);
}
if (sftp->stat_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->stat_packet);
}
if (sftp->symlink_packet) {
LIBSSH2_FREE(sftp->channel->session, sftp->symlink_packet);
}
return libssh2_channel_free(sftp->channel);
}
/* }}} */