[PATCH 2/7] winhttp: Get rid of domain_t.
Hans Leidekker
hans at codeweavers.com
Tue Nov 6 09:08:59 CST 2018
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
dlls/winhttp/cookie.c | 37 ++++++++++++++++++++++++++++---------
dlls/winhttp/session.c | 8 +-------
dlls/winhttp/winhttp_private.h | 9 +--------
3 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/dlls/winhttp/cookie.c b/dlls/winhttp/cookie.c
index 098db68e95..0a7f7f0e1c 100644
--- a/dlls/winhttp/cookie.c
+++ b/dlls/winhttp/cookie.c
@@ -38,11 +38,18 @@ struct cookie
WCHAR *path;
};
-static domain_t *add_domain( session_t *session, WCHAR *name )
+struct domain
{
- domain_t *domain;
+ struct list entry;
+ WCHAR *name;
+ struct list cookies;
+};
- if (!(domain = heap_alloc_zero( sizeof(domain_t) ))) return NULL;
+static struct domain *add_domain( session_t *session, WCHAR *name )
+{
+ struct domain *domain;
+
+ if (!(domain = heap_alloc_zero( sizeof(struct domain) ))) return NULL;
list_init( &domain->entry );
list_init( &domain->cookies );
@@ -54,7 +61,7 @@ static domain_t *add_domain( session_t *session, WCHAR *name )
return domain;
}
-static struct cookie *find_cookie( domain_t *domain, const WCHAR *path, const WCHAR *name )
+static struct cookie *find_cookie( struct domain *domain, const WCHAR *path, const WCHAR *name )
{
struct list *item;
struct cookie *cookie;
@@ -71,7 +78,7 @@ static struct cookie *find_cookie( domain_t *domain, const WCHAR *path, const WC
return NULL;
}
-static BOOL domain_match( const WCHAR *name, domain_t *domain, BOOL partial )
+static BOOL domain_match( const WCHAR *name, struct domain *domain, BOOL partial )
{
TRACE("comparing %s with %s\n", debugstr_w(name), debugstr_w(domain->name));
@@ -94,7 +101,7 @@ static void delete_cookie( struct cookie *cookie )
free_cookie( cookie );
}
-void delete_domain( domain_t *domain )
+static void delete_domain( struct domain *domain )
{
struct cookie *cookie;
struct list *item, *next;
@@ -110,9 +117,21 @@ void delete_domain( domain_t *domain )
heap_free( domain );
}
+void destroy_cookies( session_t *session )
+{
+ struct list *item, *next;
+ struct domain *domain;
+
+ LIST_FOR_EACH_SAFE( item, next, &session->cookie_cache )
+ {
+ domain = LIST_ENTRY( item, struct domain, entry );
+ delete_domain( domain );
+ }
+}
+
static BOOL add_cookie( session_t *session, struct cookie *cookie, WCHAR *domain_name, WCHAR *path )
{
- domain_t *domain = NULL;
+ struct domain *domain = NULL;
struct cookie *old_cookie;
struct list *item;
@@ -122,7 +141,7 @@ static BOOL add_cookie( session_t *session, struct cookie *cookie, WCHAR *domain
LIST_FOR_EACH( item, &session->cookie_cache )
{
- domain = LIST_ENTRY( item, domain_t, entry );
+ domain = LIST_ENTRY( item, struct domain, entry );
if (domain_match( domain_name, domain, FALSE )) break;
domain = NULL;
}
@@ -311,7 +330,7 @@ BOOL add_cookie_headers( request_t *request )
LIST_FOR_EACH( domain_cursor, &session->cookie_cache )
{
- domain_t *domain = LIST_ENTRY( domain_cursor, domain_t, entry );
+ struct domain *domain = LIST_ENTRY( domain_cursor, struct domain, entry );
if (domain_match( request->connect->servername, domain, TRUE ))
{
struct list *cookie_cursor;
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index b9d9ab8e1f..d5896e1137 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -89,19 +89,13 @@ BOOL WINAPI WinHttpCheckPlatform( void )
static void session_destroy( object_header_t *hdr )
{
session_t *session = (session_t *)hdr;
- struct list *item, *next;
- domain_t *domain;
TRACE("%p\n", session);
if (session->unload_event) SetEvent( session->unload_event );
if (session->cred_handle_initialized) FreeCredentialsHandle( &session->cred_handle );
+ destroy_cookies( session );
- LIST_FOR_EACH_SAFE( item, next, &session->cookie_cache )
- {
- domain = LIST_ENTRY( item, domain_t, entry );
- delete_domain( domain );
- }
session->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &session->cs );
heap_free( session->agent );
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 2ea798bb12..708840096a 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -66,13 +66,6 @@ struct _object_header_t
struct list children;
};
-typedef struct
-{
- struct list entry;
- WCHAR *name;
- struct list cookies;
-} domain_t;
-
typedef struct {
struct list entry;
LONG ref;
@@ -295,7 +288,7 @@ int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN;
BOOL set_cookies( request_t *, const WCHAR * ) DECLSPEC_HIDDEN;
BOOL add_cookie_headers( request_t * ) DECLSPEC_HIDDEN;
BOOL add_request_headers( request_t *, LPCWSTR, DWORD, DWORD ) DECLSPEC_HIDDEN;
-void delete_domain( domain_t * ) DECLSPEC_HIDDEN;
+void destroy_cookies( session_t * ) DECLSPEC_HIDDEN;
BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN;
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
--
2.11.0
More information about the wine-devel
mailing list