From 2ee89aa25780ff68a2fe06839e306bf70471a3a8 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 6 Nov 2018 16:08:59 +0100 Subject: [PATCH] winhttp: Get rid of domain_t. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- 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 098db68e952..0a7f7f0e1cf 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 b9d9ab8e1fd..d5896e1137f 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 2ea798bb12f..708840096a2 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.4.GIT