Now uses Curl_ as prefix for internal global symbols. curl_ should only be

used for "exported" globals.
This commit is contained in:
Daniel Stenberg 2002-04-27 13:07:51 +00:00
parent 1c42779845
commit 8358505b6d
5 changed files with 47 additions and 48 deletions

View File

@ -238,7 +238,7 @@ CURLcode curl_easy_perform(CURL *curl)
data->hostcache = Curl_global_host_cache_get(); data->hostcache = Curl_global_host_cache_get();
} }
else { 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; struct SessionHandle *data = (struct SessionHandle *)curl;
if (!Curl_global_host_cache_use(data)) { if (!Curl_global_host_cache_use(data)) {
curl_hash_destroy(data->hostcache); Curl_hash_destroy(data->hostcache);
} }
Curl_close(data); Curl_close(data);
} }

View File

@ -45,19 +45,18 @@ typedef struct _curl_hash_element {
} curl_hash_element; } curl_hash_element;
void curl_hash_init(curl_hash *, int, curl_hash_dtor); void Curl_hash_init(curl_hash *, int, curl_hash_dtor);
curl_hash *curl_hash_alloc(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_add(curl_hash *, char *, size_t, const void *);
int curl_hash_delete(curl_hash *h, char *key, size_t key_len); int Curl_hash_delete(curl_hash *h, char *key, size_t key_len);
int curl_hash_find(curl_hash *, char *, size_t, void **p); 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 *)); void Curl_hash_apply(curl_hash *h, void *user, void (*cb)(void *, curl_hash_element *));
int curl_hash_count(curl_hash *h); int Curl_hash_count(curl_hash *h);
void curl_hash_clean(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_clean_with_criterium(curl_hash *h, void *user, int (*comp)(void *, void *));
void curl_hash_destroy(curl_hash *h); void Curl_hash_destroy(curl_hash *h);
#define curl_hash_update curl_hash_add
#define Curl_hash_update Curl_hash_add
#endif #endif

View File

@ -79,7 +79,7 @@ static int host_cache_initialized;
void Curl_global_host_cache_init(void) void Curl_global_host_cache_init(void)
{ {
if (!host_cache_initialized) { if (!host_cache_initialized) {
curl_hash_init(&hostname_cache, 7, Curl_freeaddrinfo); Curl_hash_init(&hostname_cache, 7, Curl_freeaddrinfo);
host_cache_initialized = 1; host_cache_initialized = 1;
} }
} }
@ -92,7 +92,7 @@ curl_hash *Curl_global_host_cache_get(void)
void Curl_global_host_cache_dtor(void) void Curl_global_host_cache_dtor(void)
{ {
if (host_cache_initialized) { if (host_cache_initialized) {
curl_hash_clean(&hostname_cache); Curl_hash_clean(&hostname_cache);
host_cache_initialized = 0; host_cache_initialized = 0;
} }
} }
@ -152,7 +152,7 @@ _create_hostcache_id(char *server, int port, ssize_t *entry_len)
return id; return id;
} }
struct _curl_hostcache_prune_data { struct hostcache_prune_data {
int cache_timeout; int cache_timeout;
int now; int now;
}; };
@ -160,8 +160,8 @@ struct _curl_hostcache_prune_data {
static int static int
_curl_hostcache_timestamp_remove(void *datap, void *hc) _curl_hostcache_timestamp_remove(void *datap, void *hc)
{ {
struct _curl_hostcache_prune_data *data = struct hostcache_prune_data *data =
(struct _curl_hostcache_prune_data *) datap; (struct hostcache_prune_data *) datap;
struct curl_dns_cache_entry *c = (struct curl_dns_cache_entry *) hc; struct curl_dns_cache_entry *c = (struct curl_dns_cache_entry *) hc;
if (data->now - c->timestamp < data->cache_timeout) { if (data->now - c->timestamp < data->cache_timeout) {
@ -172,14 +172,14 @@ _curl_hostcache_timestamp_remove(void *datap, void *hc)
} }
static void 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.cache_timeout = cache_timeout;
user.now = now; user.now = now;
curl_hash_clean_with_criterium(hostcache, Curl_hash_clean_with_criterium(hostcache,
(void *) &user, (void *) &user,
_curl_hostcache_timestamp_remove); _curl_hostcache_timestamp_remove);
} }
@ -210,9 +210,9 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data,
time(&now); time(&now);
/* Remove outdated entries from the hostcache */ /* Remove outdated entries from the hostcache */
_curl_hostcache_prune(data->hostcache, hostcache_prune(data->hostcache,
data->set.dns_cache_timeout, data->set.dns_cache_timeout,
now); now);
/* Create an entry id, based upon the hostname and port */ /* Create an entry id, based upon the hostname and port */
entry_len = strlen(hostname); entry_len = strlen(hostname);
@ -225,7 +225,7 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data,
/* See if its already in our dns cache */ /* See if its already in our dns cache */
if (entry_id && 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); _hostcache_return(p->addr);
} }
@ -244,7 +244,7 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data,
p->timestamp = now; p->timestamp = now;
/* Save it in our host cache */ /* 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); _hostcache_return(p->addr);
} }

View File

@ -33,7 +33,7 @@
#include "memdebug.h" #include "memdebug.h"
#endif #endif
void 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->size = 0;
l->dtor = dtor; l->dtor = dtor;
@ -42,7 +42,7 @@ curl_llist_init(curl_llist *l, curl_llist_dtor dtor)
} }
curl_llist * curl_llist *
curl_llist_alloc(curl_llist_dtor dtor) Curl_llist_alloc(curl_llist_dtor dtor)
{ {
curl_llist *list; curl_llist *list;
@ -50,13 +50,13 @@ curl_llist_alloc(curl_llist_dtor dtor)
if(NULL == list) if(NULL == list)
return NULL; return NULL;
curl_llist_init(list, dtor); Curl_llist_init(list, dtor);
return list; return list;
} }
int 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; curl_llist_element *ne;
@ -84,7 +84,7 @@ curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p)
} }
int 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; curl_llist_element *ne;
@ -111,7 +111,7 @@ curl_llist_insert_prev(curl_llist *list, curl_llist_element *e, const void *p)
} }
int 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) if (e == NULL || list->size == 0)
return 1; return 1;
@ -139,28 +139,28 @@ curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user)
} }
int 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 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 size_t
curl_llist_count(curl_llist *list) Curl_llist_count(curl_llist *list)
{ {
return list->size; return list->size;
} }
void void
curl_llist_destroy(curl_llist *list, void *user) Curl_llist_destroy(curl_llist *list, void *user)
{ {
while (list->size > 0) { while (list->size > 0) {
curl_llist_remove(list, CURL_LLIST_TAIL(list), user); Curl_llist_remove(list, CURL_LLIST_TAIL(list), user);
} }
free(list); free(list);

View File

@ -44,14 +44,14 @@ typedef struct _curl_llist {
size_t size; size_t size;
} curl_llist; } curl_llist;
void curl_llist_init(curl_llist *, curl_llist_dtor); void Curl_llist_init(curl_llist *, curl_llist_dtor);
curl_llist *curl_llist_alloc(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_next(curl_llist *, curl_llist_element *, const void *);
int curl_llist_insert_prev(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(curl_llist *, curl_llist_element *, void *);
int curl_llist_remove_next(curl_llist *, curl_llist_element *, void *); int Curl_llist_remove_next(curl_llist *, curl_llist_element *, void *);
size_t curl_llist_count(curl_llist *); size_t Curl_llist_count(curl_llist *);
void curl_llist_destroy(curl_llist *, void *); void Curl_llist_destroy(curl_llist *, void *);
#define CURL_LLIST_HEAD(__l) ((__l)->head) #define CURL_LLIST_HEAD(__l) ((__l)->head)
#define CURL_LLIST_TAIL(__l) ((__l)->tail) #define CURL_LLIST_TAIL(__l) ((__l)->tail)