11 #ifndef TOR_SMARTLIST_CORE_H
12 #define TOR_SMARTLIST_CORE_H
40 #define smartlist_free(sl) FREE_AND_NULL(smartlist_t, smartlist_free_, (sl))
55 #ifdef DEBUG_SMARTLIST
60 static inline int smartlist_len(
const smartlist_t *sl);
61 static inline int smartlist_len(
const smartlist_t *sl) {
63 return (sl)->num_used;
67 static inline void *smartlist_get(
const smartlist_t *sl,
int idx);
68 static inline void *smartlist_get(
const smartlist_t *sl,
int idx) {
71 raw_assert(sl->num_used > idx);
74 static inline void smartlist_set(
smartlist_t *sl,
int idx,
void *val) {
77 raw_assert(sl->num_used > idx);
81 #define smartlist_len(sl) ((sl)->num_used)
82 #define smartlist_get(sl, idx) ((sl)->list[idx])
83 #define smartlist_set(sl, idx, val) ((sl)->list[idx] = (val))
91 void *elt = smartlist_get(sl, idx1);
92 smartlist_set(sl, idx1, smartlist_get(sl, idx2));
93 smartlist_set(sl, idx2, elt);
Utility macros to handle different features and behavior in different compilers.
void smartlist_grow(smartlist_t *sl, size_t new_size)
void smartlist_insert(smartlist_t *sl, int idx, void *val)
void smartlist_remove_keeporder(smartlist_t *sl, const void *element)
void * smartlist_pop_last(smartlist_t *sl)
static void smartlist_swap(smartlist_t *sl, int idx1, int idx2)
smartlist_t * smartlist_new(void)
void smartlist_add_strdup(struct smartlist_t *sl, const char *string)
int smartlist_contains(const smartlist_t *sl, const void *element)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_clear(smartlist_t *sl)
void smartlist_remove(smartlist_t *sl, const void *element)
void smartlist_free_(smartlist_t *sl)
void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2)
void smartlist_del(smartlist_t *sl, int idx)
void smartlist_del_keeporder(smartlist_t *sl, int idx)
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Integer definitions used throughout Tor.