Start converting circuitlist to smartlist.

This commit is contained in:
Nick Mathewson 2014-08-15 15:42:14 -04:00
parent be231b0db1
commit db2af2abb0
3 changed files with 8 additions and 9 deletions

View File

@ -38,8 +38,7 @@
/********* START VARIABLES **********/
/** A global list of all circuits at this hop. */
struct global_circuitlist_s global_circuitlist =
TOR_LIST_HEAD_INITIALIZER(global_circuitlist);
static smartlist_t *global_circuitlist = NULL;
/** A list of all the circuits in CIRCUIT_STATE_CHAN_WAIT. */
static smartlist_t *circuits_pending_chans = NULL;
@ -458,10 +457,12 @@ circuit_close_all_marked(void)
}
/** Return the head of the global linked list of circuits. */
MOCK_IMPL(struct global_circuitlist_s *,
MOCK_IMPL(smartlist_t *,
circuit_get_global_list,(void))
{
return &global_circuitlist;
if (NULL == global_circuitlist)
global_circuitlist = smartlist_new();
return global_circuitlist;
}
/** Function to make circ-\>state human-readable */

View File

@ -14,9 +14,7 @@
#include "testsupport.h"
TOR_LIST_HEAD(global_circuitlist_s, circuit_t);
MOCK_DECL(struct global_circuitlist_s*, circuit_get_global_list, (void));
MOCK_DECL(smartlist_t *, circuit_get_global_list, (void));
const char *circuit_state_to_string(int state);
const char *circuit_purpose_to_controller_string(uint8_t purpose);
const char *circuit_purpose_to_controller_hs_state_string(uint8_t purpose);

View File

@ -2864,8 +2864,8 @@ typedef struct circuit_t {
/** Unique ID for measuring tunneled network status requests. */
uint64_t dirreq_id;
/** Next circuit in linked list of all circuits (global_circuitlist). */
TOR_LIST_ENTRY(circuit_t) head;
/** Index in smartlist of all circuits (global_circuitlist). */
int global_circuitlist_idx;
/** Next circuit in the doubly-linked ring of circuits waiting to add
* cells to n_conn. NULL if we have no cells pending, or if we're not