Commit 22077714 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Add wrapper macros for set_first() and set_next(), which have the return type...

Add wrapper macros for set_first() and set_next(), which have the return type as additional parameter.
parent 7d61ad5f
......@@ -171,6 +171,8 @@ FIRM_API set_entry *set_hinsert0(set *set, const void *key, size_t size, unsigne
*/
FIRM_API void *set_first(set *set);
#define set_first(type, set) ((type*)set_first((set)))
/**
* Returns the next element of a set.
*
......@@ -181,6 +183,8 @@ FIRM_API void *set_first(set *set);
*/
FIRM_API void *set_next(set *set);
#define set_next(type, set) ((type*)set_next((set)))
/**
* Breaks the iteration of a set. Must be called before
* the next set_first() call if the iteration was NOT
......@@ -197,7 +201,7 @@ FIRM_API void set_break(set *set);
* @param type type of iterator variable
* @param entry the iterator
*/
#define foreach_set(set, type, entry) for (entry = (type*)set_first(set); entry; entry = (type*)set_next(set))
#define foreach_set(set, type, entry) for (entry = set_first(type, set); entry; entry = set_next(type, set))
/** @cond PRIVATE */
......
......@@ -104,12 +104,12 @@ size_t pmap_count(pmap *map)
pmap_entry *pmap_first(pmap *map)
{
return (pmap_entry *) set_first(M2S(map));
return set_first(pmap_entry, M2S(map));
}
pmap_entry *pmap_next(pmap *map)
{
return (pmap_entry *) set_next(M2S(map));
return set_next(pmap_entry, M2S(map));
}
void pmap_break(pmap *map)
......
......@@ -168,7 +168,7 @@ static inline int iter_step(SET *table)
/*
* finds the first entry in the table
*/
void * MANGLEP(first) (SET *table)
void *(MANGLEP(first))(SET *table)
{
assert (!table->iter_tail);
table->iter_i = 0;
......@@ -184,7 +184,7 @@ void * MANGLEP(first) (SET *table)
/*
* returns next entry in the table
*/
void *MANGLEP(next) (SET *table)
void *(MANGLEP(next))(SET *table)
{
if (!table->iter_tail)
return NULL;
......
......@@ -401,8 +401,7 @@ static void build_clique_star_cstr(ilp_env_t *ienv)
bool growed;
/* get 2 starting nodes to form a clique */
for (e=(edge_t*)set_first(edges); !e->n1; e=(edge_t*)set_next(edges)) {
}
for (e = set_first(edge_t, edges); !e->n1; e = set_next(edge_t, edges)) {}
/* we could be stepped out of the loop before the set iterated to the end */
set_break(edges);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment