Do proper referencing and unreferencing of
GWinHttpFileInputStream::file and
GWinHttpFileInputStream::file::vfs. Implement
GWinHttpFileInputStream::close_fn.
#include <string.h>
#include <wchar.h>
#include <string.h>
#include <wchar.h>
g_free (file->url.lpszUrlPath);
g_free (file->url.lpszExtraInfo);
g_free (file->url.lpszUrlPath);
g_free (file->url.lpszExtraInfo);
+ g_object_unref (file->vfs);
+
G_OBJECT_CLASS (g_winhttp_file_parent_class)->finalize (object);
}
G_OBJECT_CLASS (g_winhttp_file_parent_class)->finalize (object);
}
return NULL;
file = g_object_new (G_TYPE_WINHTTP_FILE, NULL);
return NULL;
file = g_object_new (G_TYPE_WINHTTP_FILE, NULL);
+ file->vfs = g_object_ref (vfs);
memset (&file->url, 0, sizeof (file->url));
file->url.dwStructSize = sizeof (file->url);
memset (&file->url, 0, sizeof (file->url));
file->url.dwStructSize = sizeof (file->url);
GCancellable *cancellable,
GError **error);
GCancellable *cancellable,
GError **error);
+static gboolean g_winhttp_file_input_stream_close (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error);
+
static void
g_winhttp_file_input_stream_finalize (GObject *object)
{
static void
g_winhttp_file_input_stream_finalize (GObject *object)
{
if (winhttp_stream->connection != NULL)
G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
if (winhttp_stream->connection != NULL)
G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
+ g_object_unref (winhttp_stream->file);
+ winhttp_stream->file = NULL;
+
G_OBJECT_CLASS (g_winhttp_file_input_stream_parent_class)->finalize (object);
}
G_OBJECT_CLASS (g_winhttp_file_input_stream_parent_class)->finalize (object);
}
gobject_class->finalize = g_winhttp_file_input_stream_finalize;
stream_class->read_fn = g_winhttp_file_input_stream_read;
gobject_class->finalize = g_winhttp_file_input_stream_finalize;
stream_class->read_fn = g_winhttp_file_input_stream_read;
+ stream_class->close_fn = g_winhttp_file_input_stream_close;
stream = g_object_new (G_TYPE_WINHTTP_FILE_INPUT_STREAM, NULL);
stream = g_object_new (G_TYPE_WINHTTP_FILE_INPUT_STREAM, NULL);
+ stream->file = g_object_ref (file);
stream->request_sent = FALSE;
stream->connection = connection;
stream->request = request;
stream->request_sent = FALSE;
stream->connection = connection;
stream->request = request;
+
+static gboolean
+g_winhttp_file_input_stream_close (GInputStream *stream,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GWinHttpFileInputStream *winhttp_stream = G_WINHTTP_FILE_INPUT_STREAM (stream);
+
+ if (winhttp_stream->connection != NULL)
+ G_WINHTTP_VFS_GET_CLASS (winhttp_stream->file->vfs)->funcs->pWinHttpCloseHandle (winhttp_stream->connection);
+ winhttp_stream->connection = NULL;
+ return TRUE;
+}