mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48:49 -05:00
Use plain structs and not typedef'ed ones in the hash and linked-list code.
This commit is contained in:
parent
4f7e958969
commit
043d70fcdf
59
lib/hash.c
59
lib/hash.c
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -50,12 +50,11 @@ hash_str(const char *key, size_t key_length)
|
|||||||
static void
|
static void
|
||||||
hash_element_dtor(void *user, void *element)
|
hash_element_dtor(void *user, void *element)
|
||||||
{
|
{
|
||||||
curl_hash *h = (curl_hash *) user;
|
struct curl_hash *h = (struct curl_hash *) user;
|
||||||
curl_hash_element *e = (curl_hash_element *) element;
|
struct curl_hash_element *e = (struct curl_hash_element *) element;
|
||||||
|
|
||||||
if (e->key) {
|
if (e->key)
|
||||||
free(e->key);
|
free(e->key);
|
||||||
}
|
|
||||||
|
|
||||||
h->dtor(e->ptr);
|
h->dtor(e->ptr);
|
||||||
|
|
||||||
@ -64,7 +63,7 @@ hash_element_dtor(void *user, void *element)
|
|||||||
|
|
||||||
/* return 1 on error, 0 is fine */
|
/* return 1 on error, 0 is fine */
|
||||||
int
|
int
|
||||||
Curl_hash_init(curl_hash *h, int slots, curl_hash_dtor dtor)
|
Curl_hash_init(struct curl_hash *h, int slots, curl_hash_dtor dtor)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -72,7 +71,7 @@ Curl_hash_init(curl_hash *h, int slots, curl_hash_dtor dtor)
|
|||||||
h->size = 0;
|
h->size = 0;
|
||||||
h->slots = slots;
|
h->slots = slots;
|
||||||
|
|
||||||
h->table = (curl_llist **) malloc(slots * sizeof(curl_llist *));
|
h->table = (struct curl_llist **) malloc(slots * sizeof(struct curl_llist *));
|
||||||
if(h->table) {
|
if(h->table) {
|
||||||
for (i = 0; i < slots; ++i) {
|
for (i = 0; i < slots; ++i) {
|
||||||
h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor);
|
h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor);
|
||||||
@ -89,12 +88,12 @@ Curl_hash_init(curl_hash *h, int slots, curl_hash_dtor dtor)
|
|||||||
return 1; /* failure */
|
return 1; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_hash *
|
struct curl_hash *
|
||||||
Curl_hash_alloc(int slots, curl_hash_dtor dtor)
|
Curl_hash_alloc(int slots, curl_hash_dtor dtor)
|
||||||
{
|
{
|
||||||
curl_hash *h;
|
struct curl_hash *h;
|
||||||
|
|
||||||
h = (curl_hash *) malloc(sizeof(curl_hash));
|
h = (struct curl_hash *) malloc(sizeof(struct curl_hash));
|
||||||
if (h) {
|
if (h) {
|
||||||
if(Curl_hash_init(h, slots, dtor)) {
|
if(Curl_hash_init(h, slots, dtor)) {
|
||||||
/* failure */
|
/* failure */
|
||||||
@ -118,11 +117,11 @@ hash_key_compare(char *key1, size_t key1_len, char *key2, size_t key2_len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static curl_hash_element *
|
static struct curl_hash_element *
|
||||||
mk_hash_element(char *key, size_t key_len, const void *p)
|
mk_hash_element(char *key, size_t key_len, const void *p)
|
||||||
{
|
{
|
||||||
curl_hash_element *he =
|
struct curl_hash_element *he =
|
||||||
(curl_hash_element *) malloc(sizeof(curl_hash_element));
|
(struct curl_hash_element *) malloc(sizeof(struct curl_hash_element));
|
||||||
|
|
||||||
if(he) {
|
if(he) {
|
||||||
char *dup = strdup(key);
|
char *dup = strdup(key);
|
||||||
@ -147,14 +146,14 @@ mk_hash_element(char *key, size_t key_len, const void *p)
|
|||||||
/* Return the data in the hash. If there already was a match in the hash,
|
/* Return the data in the hash. If there already was a match in the hash,
|
||||||
that data is returned. */
|
that data is returned. */
|
||||||
void *
|
void *
|
||||||
Curl_hash_add(curl_hash *h, char *key, size_t key_len, void *p)
|
Curl_hash_add(struct curl_hash *h, char *key, size_t key_len, void *p)
|
||||||
{
|
{
|
||||||
curl_hash_element *he;
|
struct curl_hash_element *he;
|
||||||
curl_llist_element *le;
|
struct curl_llist_element *le;
|
||||||
curl_llist *l = FETCH_LIST(h, key, key_len);
|
struct curl_llist *l = FETCH_LIST(h, key, key_len);
|
||||||
|
|
||||||
for (le = l->head; le; le = le->next) {
|
for (le = l->head; le; le = le->next) {
|
||||||
he = (curl_hash_element *) le->ptr;
|
he = (struct curl_hash_element *) le->ptr;
|
||||||
if (hash_key_compare(he->key, he->key_len, key, key_len)) {
|
if (hash_key_compare(he->key, he->key_len, key, key_len)) {
|
||||||
h->dtor(p); /* remove the NEW entry */
|
h->dtor(p); /* remove the NEW entry */
|
||||||
return he->ptr; /* return the EXISTING entry */
|
return he->ptr; /* return the EXISTING entry */
|
||||||
@ -181,11 +180,11 @@ Curl_hash_add(curl_hash *h, char *key, size_t key_len, void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
Curl_hash_pick(curl_hash *h, char *key, size_t key_len)
|
Curl_hash_pick(struct curl_hash *h, char *key, size_t key_len)
|
||||||
{
|
{
|
||||||
curl_llist_element *le;
|
struct curl_llist_element *le;
|
||||||
curl_hash_element *he;
|
struct curl_hash_element *he;
|
||||||
curl_llist *l = FETCH_LIST(h, key, key_len);
|
struct curl_llist *l = FETCH_LIST(h, key, key_len);
|
||||||
|
|
||||||
for (le = l->head;
|
for (le = l->head;
|
||||||
le;
|
le;
|
||||||
@ -204,7 +203,7 @@ void
|
|||||||
Curl_hash_apply(curl_hash *h, void *user,
|
Curl_hash_apply(curl_hash *h, void *user,
|
||||||
void (*cb)(void *user, void *ptr))
|
void (*cb)(void *user, void *ptr))
|
||||||
{
|
{
|
||||||
curl_llist_element *le;
|
struct curl_llist_element *le;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < h->slots; ++i) {
|
for (i = 0; i < h->slots; ++i) {
|
||||||
@ -219,7 +218,7 @@ Curl_hash_apply(curl_hash *h, void *user,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
Curl_hash_clean(curl_hash *h)
|
Curl_hash_clean(struct curl_hash *h)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -231,19 +230,19 @@ Curl_hash_clean(curl_hash *h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Curl_hash_clean_with_criterium(curl_hash *h, void *user,
|
Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
|
||||||
int (*comp)(void *, void *))
|
int (*comp)(void *, void *))
|
||||||
{
|
{
|
||||||
curl_llist_element *le;
|
struct curl_llist_element *le;
|
||||||
curl_llist_element *lnext;
|
struct curl_llist_element *lnext;
|
||||||
curl_llist *list;
|
struct curl_llist *list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < h->slots; ++i) {
|
for (i = 0; i < h->slots; ++i) {
|
||||||
list = h->table[i];
|
list = h->table[i];
|
||||||
le = list->head; /* get first list entry */
|
le = list->head; /* get first list entry */
|
||||||
while(le) {
|
while(le) {
|
||||||
curl_hash_element *he = le->ptr;
|
struct curl_hash_element *he = le->ptr;
|
||||||
lnext = le->next;
|
lnext = le->next;
|
||||||
/* ask the callback function if we shall remove this entry or not */
|
/* ask the callback function if we shall remove this entry or not */
|
||||||
if (comp(user, he->ptr)) {
|
if (comp(user, he->ptr)) {
|
||||||
@ -256,7 +255,7 @@ Curl_hash_clean_with_criterium(curl_hash *h, void *user,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Curl_hash_destroy(curl_hash *h)
|
Curl_hash_destroy(struct curl_hash *h)
|
||||||
{
|
{
|
||||||
if (!h)
|
if (!h)
|
||||||
return;
|
return;
|
||||||
|
37
lib/hash.h
37
lib/hash.h
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -31,30 +31,31 @@
|
|||||||
|
|
||||||
typedef void (*curl_hash_dtor)(void *);
|
typedef void (*curl_hash_dtor)(void *);
|
||||||
|
|
||||||
typedef struct _curl_hash {
|
struct curl_hash {
|
||||||
curl_llist **table;
|
struct curl_llist **table;
|
||||||
curl_hash_dtor dtor;
|
curl_hash_dtor dtor;
|
||||||
int slots;
|
int slots;
|
||||||
size_t size;
|
size_t size;
|
||||||
} curl_hash;
|
};
|
||||||
|
|
||||||
typedef struct _curl_hash_element {
|
struct curl_hash_element {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
char *key;
|
char *key;
|
||||||
size_t key_len;
|
size_t key_len;
|
||||||
} curl_hash_element;
|
};
|
||||||
|
|
||||||
|
|
||||||
int Curl_hash_init(curl_hash *, int, curl_hash_dtor);
|
int Curl_hash_init(struct curl_hash *, int, curl_hash_dtor);
|
||||||
curl_hash *Curl_hash_alloc(int, curl_hash_dtor);
|
struct curl_hash *Curl_hash_alloc(int, curl_hash_dtor);
|
||||||
void *Curl_hash_add(curl_hash *, char *, size_t, void *);
|
void *Curl_hash_add(struct curl_hash *, char *, size_t, void *);
|
||||||
int Curl_hash_delete(curl_hash *h, char *key, size_t key_len);
|
int Curl_hash_delete(struct curl_hash *h, char *key, size_t key_len);
|
||||||
void *Curl_hash_pick(curl_hash *, char *, size_t);
|
void *Curl_hash_pick(struct curl_hash *, char *, size_t);
|
||||||
void Curl_hash_apply(curl_hash *h, void *user,
|
void Curl_hash_apply(struct curl_hash *h, void *user,
|
||||||
void (*cb)(void *user, void *ptr));
|
void (*cb)(void *user, void *ptr));
|
||||||
int Curl_hash_count(curl_hash *h);
|
int Curl_hash_count(struct curl_hash *h);
|
||||||
void Curl_hash_clean(curl_hash *h);
|
void Curl_hash_clean(struct curl_hash *h);
|
||||||
void Curl_hash_clean_with_criterium(curl_hash *h, void *user, int (*comp)(void *, void *));
|
void Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
|
||||||
void Curl_hash_destroy(curl_hash *h);
|
int (*comp)(void *, void *));
|
||||||
|
void Curl_hash_destroy(struct curl_hash *h);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
lib/hostip.c
10
lib/hostip.c
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -131,7 +131,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* These two symbols are for the global DNS cache */
|
/* These two symbols are for the global DNS cache */
|
||||||
static curl_hash hostname_cache;
|
static struct curl_hash hostname_cache;
|
||||||
static int host_cache_initialized;
|
static int host_cache_initialized;
|
||||||
|
|
||||||
static void freednsentry(void *freethis);
|
static void freednsentry(void *freethis);
|
||||||
@ -152,7 +152,7 @@ void Curl_global_host_cache_init(void)
|
|||||||
/*
|
/*
|
||||||
* Return a pointer to the global cache
|
* Return a pointer to the global cache
|
||||||
*/
|
*/
|
||||||
curl_hash *Curl_global_host_cache_get(void)
|
struct curl_hash *Curl_global_host_cache_get(void)
|
||||||
{
|
{
|
||||||
return &hostname_cache;
|
return &hostname_cache;
|
||||||
}
|
}
|
||||||
@ -244,7 +244,7 @@ hostcache_timestamp_remove(void *datap, void *hc)
|
|||||||
* Prune the DNS cache. This assumes that a lock has already been taken.
|
* Prune the DNS cache. This assumes that a lock has already been taken.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
hostcache_prune(curl_hash *hostcache, int cache_timeout, time_t now)
|
hostcache_prune(struct curl_hash *hostcache, int cache_timeout, time_t now)
|
||||||
{
|
{
|
||||||
struct hostcache_prune_data user;
|
struct hostcache_prune_data user;
|
||||||
|
|
||||||
@ -507,7 +507,7 @@ static void freednsentry(void *freethis)
|
|||||||
/*
|
/*
|
||||||
* Curl_mk_dnscache() creates a new DNS cache and returns the handle for it.
|
* Curl_mk_dnscache() creates a new DNS cache and returns the handle for it.
|
||||||
*/
|
*/
|
||||||
curl_hash *Curl_mk_dnscache(void)
|
struct curl_hash *Curl_mk_dnscache(void)
|
||||||
{
|
{
|
||||||
return Curl_hash_alloc(7, freednsentry);
|
return Curl_hash_alloc(7, freednsentry);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -112,7 +112,7 @@ struct connectdata;
|
|||||||
|
|
||||||
void Curl_global_host_cache_init(void);
|
void Curl_global_host_cache_init(void);
|
||||||
void Curl_global_host_cache_dtor(void);
|
void Curl_global_host_cache_dtor(void);
|
||||||
curl_hash *Curl_global_host_cache_get(void);
|
struct curl_hash *Curl_global_host_cache_get(void);
|
||||||
|
|
||||||
#define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
|
#define Curl_global_host_cache_use(__p) ((__p)->set.global_dns_cache)
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ void Curl_scan_cache_used(void *user, void *ptr);
|
|||||||
void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
|
void Curl_freeaddrinfo(Curl_addrinfo *freeaddr);
|
||||||
|
|
||||||
/* make a new dns cache and return the handle */
|
/* make a new dns cache and return the handle */
|
||||||
curl_hash *Curl_mk_dnscache(void);
|
struct curl_hash *Curl_mk_dnscache(void);
|
||||||
|
|
||||||
/* prune old entries from the DNS cache */
|
/* prune old entries from the DNS cache */
|
||||||
void Curl_hostcache_prune(struct SessionHandle *data);
|
void Curl_hostcache_prune(struct SessionHandle *data);
|
||||||
|
22
lib/llist.c
22
lib/llist.c
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -33,7 +33,7 @@
|
|||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
Curl_llist_init(curl_llist *l, curl_llist_dtor dtor)
|
Curl_llist_init(struct curl_llist *l, curl_llist_dtor dtor)
|
||||||
{
|
{
|
||||||
l->size = 0;
|
l->size = 0;
|
||||||
l->dtor = dtor;
|
l->dtor = dtor;
|
||||||
@ -41,12 +41,12 @@ Curl_llist_init(curl_llist *l, curl_llist_dtor dtor)
|
|||||||
l->tail = NULL;
|
l->tail = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_llist *
|
struct curl_llist *
|
||||||
Curl_llist_alloc(curl_llist_dtor dtor)
|
Curl_llist_alloc(curl_llist_dtor dtor)
|
||||||
{
|
{
|
||||||
curl_llist *list;
|
struct curl_llist *list;
|
||||||
|
|
||||||
list = (curl_llist *)malloc(sizeof(curl_llist));
|
list = (struct curl_llist *)malloc(sizeof(struct curl_llist));
|
||||||
if(NULL == list)
|
if(NULL == list)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -59,10 +59,11 @@ Curl_llist_alloc(curl_llist_dtor dtor)
|
|||||||
* Curl_llist_insert_next() returns 1 on success and 0 on failure.
|
* Curl_llist_insert_next() returns 1 on success and 0 on failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
Curl_llist_insert_next(curl_llist *list, curl_llist_element *e, const void *p)
|
Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e,
|
||||||
|
const void *p)
|
||||||
{
|
{
|
||||||
curl_llist_element *ne =
|
struct curl_llist_element *ne =
|
||||||
(curl_llist_element *) malloc(sizeof(curl_llist_element));
|
(struct curl_llist_element *) malloc(sizeof(struct curl_llist_element));
|
||||||
if(!ne)
|
if(!ne)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -91,7 +92,8 @@ Curl_llist_insert_next(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(struct curl_llist *list, struct curl_llist_element *e,
|
||||||
|
void *user)
|
||||||
{
|
{
|
||||||
if (e == NULL || list->size == 0)
|
if (e == NULL || list->size == 0)
|
||||||
return 1;
|
return 1;
|
||||||
@ -119,7 +121,7 @@ Curl_llist_remove(curl_llist *list, curl_llist_element *e, void *user)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Curl_llist_destroy(curl_llist *list, void *user)
|
Curl_llist_destroy(struct curl_llist *list, void *user)
|
||||||
{
|
{
|
||||||
if(list) {
|
if(list) {
|
||||||
while (list->size > 0)
|
while (list->size > 0)
|
||||||
|
48
lib/llist.h
48
lib/llist.h
@ -1,18 +1,18 @@
|
|||||||
#ifndef __LLIST_H
|
#ifndef __LLIST_H
|
||||||
#define __LLIST_H
|
#define __LLIST_H
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
* / __| | | | |_) | |
|
* / __| | | | |_) | |
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
* copies of the Software, and permit persons to whom the Software is
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
* furnished to do so, under the terms of the COPYING file.
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
@ -28,29 +28,33 @@
|
|||||||
|
|
||||||
typedef void (*curl_llist_dtor)(void *, void *);
|
typedef void (*curl_llist_dtor)(void *, void *);
|
||||||
|
|
||||||
typedef struct _curl_llist_element {
|
struct curl_llist_element {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
struct _curl_llist_element *prev;
|
struct curl_llist_element *prev;
|
||||||
struct _curl_llist_element *next;
|
struct curl_llist_element *next;
|
||||||
} curl_llist_element;
|
};
|
||||||
|
|
||||||
typedef struct _curl_llist {
|
struct curl_llist {
|
||||||
curl_llist_element *head;
|
struct curl_llist_element *head;
|
||||||
curl_llist_element *tail;
|
struct curl_llist_element *tail;
|
||||||
|
|
||||||
curl_llist_dtor dtor;
|
curl_llist_dtor dtor;
|
||||||
|
|
||||||
size_t size;
|
size_t size;
|
||||||
} curl_llist;
|
};
|
||||||
|
|
||||||
void Curl_llist_init(curl_llist *, curl_llist_dtor);
|
void Curl_llist_init(struct curl_llist *, curl_llist_dtor);
|
||||||
curl_llist *Curl_llist_alloc(curl_llist_dtor);
|
struct 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(struct curl_llist *, struct curl_llist_element *,
|
||||||
int Curl_llist_insert_prev(curl_llist *, curl_llist_element *, const void *);
|
const void *);
|
||||||
int Curl_llist_remove(curl_llist *, curl_llist_element *, void *);
|
int Curl_llist_insert_prev(struct curl_llist *, struct curl_llist_element *,
|
||||||
int Curl_llist_remove_next(curl_llist *, curl_llist_element *, void *);
|
const void *);
|
||||||
size_t Curl_llist_count(curl_llist *);
|
int Curl_llist_remove(struct curl_llist *, struct curl_llist_element *,
|
||||||
void Curl_llist_destroy(curl_llist *, void *);
|
void *);
|
||||||
|
int Curl_llist_remove_next(struct curl_llist *, struct curl_llist_element *,
|
||||||
|
void *);
|
||||||
|
size_t Curl_llist_count(struct curl_llist *);
|
||||||
|
void Curl_llist_destroy(struct curl_llist *, void *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -108,7 +108,7 @@ struct Curl_multi {
|
|||||||
int num_msgs; /* total amount of messages in the easy handles */
|
int num_msgs; /* total amount of messages in the easy handles */
|
||||||
|
|
||||||
/* Hostname cache */
|
/* Hostname cache */
|
||||||
curl_hash *hostcache;
|
struct curl_hash *hostcache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
29
lib/share.h
29
lib/share.h
@ -2,18 +2,18 @@
|
|||||||
#define __CURL_SHARE_H
|
#define __CURL_SHARE_H
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
* / __| | | | |_) | |
|
* / __| | | | |_) | |
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
* copies of the Software, and permit persons to whom the Software is
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
* furnished to do so, under the terms of the COPYING file.
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
@ -32,24 +32,17 @@
|
|||||||
struct Curl_share {
|
struct Curl_share {
|
||||||
unsigned int specifier;
|
unsigned int specifier;
|
||||||
volatile unsigned int dirty;
|
volatile unsigned int dirty;
|
||||||
|
|
||||||
curl_lock_function lockfunc;
|
curl_lock_function lockfunc;
|
||||||
curl_unlock_function unlockfunc;
|
curl_unlock_function unlockfunc;
|
||||||
void *clientdata;
|
void *clientdata;
|
||||||
|
|
||||||
curl_hash *hostcache;
|
struct curl_hash *hostcache;
|
||||||
struct CookieInfo *cookies;
|
struct CookieInfo *cookies;
|
||||||
};
|
};
|
||||||
|
|
||||||
CURLSHcode Curl_share_lock (
|
CURLSHcode Curl_share_lock (struct SessionHandle *, curl_lock_data,
|
||||||
struct SessionHandle *,
|
curl_lock_access);
|
||||||
curl_lock_data,
|
CURLSHcode Curl_share_unlock (struct SessionHandle *, curl_lock_data);
|
||||||
curl_lock_access
|
|
||||||
);
|
|
||||||
|
|
||||||
CURLSHcode Curl_share_unlock (
|
|
||||||
struct SessionHandle *,
|
|
||||||
curl_lock_data
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif /* __CURL_SHARE_H */
|
#endif /* __CURL_SHARE_H */
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -955,7 +955,7 @@ struct UserDefined {
|
|||||||
* 'struct urlstate' instead. */
|
* 'struct urlstate' instead. */
|
||||||
|
|
||||||
struct SessionHandle {
|
struct SessionHandle {
|
||||||
curl_hash *hostcache;
|
struct curl_hash *hostcache;
|
||||||
void *multi; /* if non-NULL, points to the multi handle
|
void *multi; /* if non-NULL, points to the multi handle
|
||||||
struct of which this "belongs" */
|
struct of which this "belongs" */
|
||||||
struct Curl_share *share; /* Share, handles global variable mutexing */
|
struct Curl_share *share; /* Share, handles global variable mutexing */
|
||||||
|
Loading…
Reference in New Issue
Block a user