diff options
-rw-r--r-- | lib/easy.c | 4 | ||||
-rw-r--r-- | lib/hash.h | 23 | ||||
-rw-r--r-- | lib/hostip.c | 26 | ||||
-rw-r--r-- | lib/llist.c | 26 | ||||
-rw-r--r-- | lib/llist.h | 16 |
5 files changed, 47 insertions, 48 deletions
diff --git a/lib/easy.c b/lib/easy.c index 12b2cac23..401eeeddf 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -238,7 +238,7 @@ CURLcode curl_easy_perform(CURL *curl) data->hostcache = Curl_global_host_cache_get(); } else { - data->hostcache = curl_hash_alloc(7, Curl_freeaddrinfo); + data->hostcache = Curl_hash_alloc(7, Curl_freeaddrinfo); } } @@ -249,7 +249,7 @@ void curl_easy_cleanup(CURL *curl) { struct SessionHandle *data = (struct SessionHandle *)curl; if (!Curl_global_host_cache_use(data)) { - curl_hash_destroy(data->hostcache); + Curl_hash_destroy(data->hostcache); } Curl_close(data); } diff --git a/lib/hash.h b/lib/hash.h index 9f4557639..8e4264df8 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -45,19 +45,18 @@ typedef struct _curl_hash_element { } curl_hash_element; -void curl_hash_init(curl_hash *, int, curl_hash_dtor); -curl_hash *curl_hash_alloc(int, curl_hash_dtor); -int curl_hash_add(curl_hash *, char *, size_t, const void *); -int curl_hash_delete(curl_hash *h, char *key, size_t key_len); -int curl_hash_find(curl_hash *, char *, size_t, void **p); -void curl_hash_apply(curl_hash *h, void *user, void (*cb)(void *, curl_hash_element *)); -int curl_hash_count(curl_hash *h); -void curl_hash_clean(curl_hash *h); -void curl_hash_clean_with_criterium(curl_hash *h, void *user, int (*comp)(void *, void *)); -void curl_hash_destroy(curl_hash *h); - -#define curl_hash_update curl_hash_add +void Curl_hash_init(curl_hash *, int, curl_hash_dtor); +curl_hash *Curl_hash_alloc(int, curl_hash_dtor); +int Curl_hash_add(curl_hash *, char *, size_t, const void *); +int Curl_hash_delete(curl_hash *h, char *key, size_t key_len); +int Curl_hash_find(curl_hash *, char *, size_t, void **p); +void Curl_hash_apply(curl_hash *h, void *user, void (*cb)(void *, curl_hash_element *)); +int Curl_hash_count(curl_hash *h); +void Curl_hash_clean(curl_hash *h); +void Curl_hash_clean_with_criterium(curl_hash *h, void *user, int (*comp)(void *, void *)); +void Curl_hash_destroy(curl_hash *h); +#define Curl_hash_update Curl_hash_add #endif diff --git a/lib/hostip.c b/lib/hostip.c index ea28b1cea..f84e26e6a 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -79,7 +79,7 @@ static int host_cache_initialized; void Curl_global_host_cache_init(void) { if (!host_cache_initialized) { - curl_hash_init(&hostname_cache, 7, Curl_freeaddrinfo); + Curl_hash_init(&hostname_cache, 7, Curl_freeaddrinfo); host_cache_initialized = 1; } } @@ -92,7 +92,7 @@ curl_hash *Curl_global_host_cache_get(void) void Curl_global_host_cache_dtor(void) { if (host_cache_initialized) { - curl_hash_clean(&hostname_cache); + Curl_hash_clean(&hostname_cache); host_cache_initialized = 0; } } @@ -152,7 +152,7 @@ _create_hostcache_id(char *server, int port, ssize_t *entry_len) return id; } -struct _curl_hostcache_prune_data { +struct hostcache_prune_data { int cache_timeout; int now; }; @@ -160,8 +160,8 @@ struct _curl_hostcache_prune_data { static int _curl_hostcache_timestamp_remove(void *datap, void *hc) { - struct _curl_hostcache_prune_data *data = - (struct _curl_hostcache_prune_data *) datap; + struct hostcache_prune_data *data = + (struct hostcache_prune_data *) datap; struct curl_dns_cache_entry *c = (struct curl_dns_cache_entry *) hc; if (data->now - c->timestamp < data->cache_timeout) { @@ -172,14 +172,14 @@ _curl_hostcache_timestamp_remove(void *datap, void *hc) } static void -_curl_hostcache_prune(curl_hash *hostcache, int cache_timeout, int now) +hostcache_prune(curl_hash *hostcache, int cache_timeout, int now) { - struct _curl_hostcache_prune_data user; + struct hostcache_prune_data user; user.cache_timeout = cache_timeout; user.now = now; - curl_hash_clean_with_criterium(hostcache, + Curl_hash_clean_with_criterium(hostcache, (void *) &user, _curl_hostcache_timestamp_remove); } @@ -210,9 +210,9 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data, time(&now); /* Remove outdated entries from the hostcache */ - _curl_hostcache_prune(data->hostcache, - data->set.dns_cache_timeout, - now); + hostcache_prune(data->hostcache, + data->set.dns_cache_timeout, + now); /* Create an entry id, based upon the hostname and port */ entry_len = strlen(hostname); @@ -225,7 +225,7 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data, /* See if its already in our dns cache */ if (entry_id && - curl_hash_find(data->hostcache, entry_id, entry_len+1, (void **) &p)) { + Curl_hash_find(data->hostcache, entry_id, entry_len+1, (void **) &p)) { _hostcache_return(p->addr); } @@ -244,7 +244,7 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data, p->timestamp = now; /* Save it in our host cache */ - curl_hash_update(data->hostcache, entry_id, entry_len+1, (const void *) p); + Curl_hash_update(data->hostcache, entry_id, entry_len+1, (const void *) p); _hostcache_return(p->addr); } diff --git a/lib/llist.c b/lib/llist.c index e84508038..7d0862032 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -33,7 +33,7 @@ #include "memdebug.h" #endif void -curl_llist_init(curl_llist *l, curl_llist_dtor dtor) +Curl_llist_init(curl_llist *l, curl_llist_dtor dtor) { l->size = 0; l->dtor = dtor; @@ -42,7 +42,7 @@ curl_llist_init(curl_llist *l, curl_llist_dtor dtor) } curl_llist * -curl_llist_alloc(curl_llist_dtor dtor) +Curl_llist_alloc(curl_llist_dtor dtor) { curl_llist *list; @@ -50,13 +50,13 @@ curl_llist_alloc(curl_llist_dtor dtor) if(NULL == list) return NULL; - curl_llist_init(list, dtor); + Curl_llist_init(list, dtor); return list; } int -curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p) +Curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p) { curl_llist_element *ne; @@ -84,7 +84,7 @@ curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p) } int -curl_llist_insert_prev(curl_llist *list, curl_llist_element *e, const void *p) +Curl_llist_insert_prev(curl_llist *list, curl_llist_element *e, const void *p) { curl_llist_element *ne; @@ -111,7 +111,7 @@ curl_llist_insert_prev(curl_llist *list, curl_llist_element *e, const void *p) } int -curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user) +Curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user) { if (e == NULL || list->size == 0) return 1; @@ -139,28 +139,28 @@ curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user) } int -curl_llist_remove_next(curl_llist *list, curl_llist_element *e, void *user) +Curl_llist_remove_next(curl_llist *list, curl_llist_element *e, void *user) { - return curl_llist_remove(list, e->next, user); + return Curl_llist_remove(list, e->next, user); } int -curl_llist_remove_prev(curl_llist *list, curl_llist_element *e, void *user) +Curl_llist_remove_prev(curl_llist *list, curl_llist_element *e, void *user) { - return curl_llist_remove(list, e->prev, user); + return Curl_llist_remove(list, e->prev, user); } size_t -curl_llist_count(curl_llist *list) +Curl_llist_count(curl_llist *list) { return list->size; } void -curl_llist_destroy(curl_llist *list, void *user) +Curl_llist_destroy(curl_llist *list, void *user) { while (list->size > 0) { - curl_llist_remove(list, CURL_LLIST_TAIL(list), user); + Curl_llist_remove(list, CURL_LLIST_TAIL(list), user); } free(list); diff --git a/lib/llist.h b/lib/llist.h index dca7ebbd2..1b6105298 100644 --- a/lib/llist.h +++ b/lib/llist.h @@ -44,14 +44,14 @@ typedef struct _curl_llist { size_t size; } curl_llist; -void curl_llist_init(curl_llist *, curl_llist_dtor); -curl_llist *curl_llist_alloc(curl_llist_dtor); -int curl_llist_insert_next(curl_llist *, curl_llist_element *, const void *); -int curl_llist_insert_prev(curl_llist *, curl_llist_element *, const void *); -int curl_llist_remove(curl_llist *, curl_llist_element *, void *); -int curl_llist_remove_next(curl_llist *, curl_llist_element *, void *); -size_t curl_llist_count(curl_llist *); -void curl_llist_destroy(curl_llist *, void *); +void Curl_llist_init(curl_llist *, curl_llist_dtor); +curl_llist *Curl_llist_alloc(curl_llist_dtor); +int Curl_llist_insert_next(curl_llist *, curl_llist_element *, const void *); +int Curl_llist_insert_prev(curl_llist *, curl_llist_element *, const void *); +int Curl_llist_remove(curl_llist *, curl_llist_element *, void *); +int Curl_llist_remove_next(curl_llist *, curl_llist_element *, void *); +size_t Curl_llist_count(curl_llist *); +void Curl_llist_destroy(curl_llist *, void *); #define CURL_LLIST_HEAD(__l) ((__l)->head) #define CURL_LLIST_TAIL(__l) ((__l)->tail) |