summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gl_list.hh16
-rw-r--r--lib/gl_map.hh12
-rw-r--r--lib/gl_omap.hh12
-rw-r--r--lib/gl_oset.hh8
-rw-r--r--lib/gl_set.hh8
5 files changed, 50 insertions, 6 deletions
diff --git a/lib/gl_list.hh b/lib/gl_list.hh
index b19bda71b1..8b0ccad1ba 100644
--- a/lib/gl_list.hh
+++ b/lib/gl_list.hh
@@ -351,13 +351,25 @@ public:
the iterator and returns true.
Otherwise, returns false. */
bool next (ELTYPE *& elt)
- { return gl_list_iterator_next (&_state, reinterpret_cast<const void **>(&elt), NULL); }
+ {
+ const void *next_elt;
+ bool has_next = gl_list_iterator_next (&_state, &next_elt, NULL);
+ if (has_next)
+ elt = static_cast<ELTYPE *>(next_elt);
+ return has_next;
+ }
/* If there is a next element, stores the next element in ELT, stores its
node in *NODEP if NODEP is non-NULL, advances the iterator and returns true.
Otherwise, returns false. */
bool next (ELTYPE *& elt, gl_list_node_t *nodep)
- { return gl_list_iterator_next (&_state, reinterpret_cast<const void **>(&elt), nodep); }
+ {
+ const void *next_elt;
+ bool has_next = gl_list_iterator_next (&_state, &next_elt, nodep);
+ if (has_next)
+ elt = static_cast<ELTYPE *>(next_elt);
+ return has_next;
+ }
~iterator ()
{ gl_list_iterator_free (&_state); }
diff --git a/lib/gl_map.hh b/lib/gl_map.hh
index f3d0a46b94..082694fe6b 100644
--- a/lib/gl_map.hh
+++ b/lib/gl_map.hh
@@ -143,7 +143,17 @@ public:
/* If there is a next pair, stores the next pair in KEY and VALUE, advance
the iterator, and returns true. Otherwise, returns false. */
bool next (KEYTYPE *& key, VALUETYPE *& value)
- { return gl_map_iterator_next (&_state, reinterpret_cast<const void **>(&key), reinterpret_cast<const void **>(&value)); }
+ {
+ const void *next_key;
+ const void *next_value;
+ bool has_next = gl_map_iterator_next (&_state, &next_key, &next_value);
+ if (has_next)
+ {
+ key = static_cast<KEYTYPE *>(next_key);
+ value = static_cast<VALUETYPE *>(next_value);
+ }
+ return has_next;
+ }
~iterator ()
{ gl_map_iterator_free (&_state); }
diff --git a/lib/gl_omap.hh b/lib/gl_omap.hh
index 15d81041d4..1f892e46f8 100644
--- a/lib/gl_omap.hh
+++ b/lib/gl_omap.hh
@@ -150,7 +150,17 @@ public:
/* If there is a next pair, stores the next pair in KEY and VALUE, advances
the iterator, and returns true. Otherwise, returns false. */
bool next (KEYTYPE *& key, VALUETYPE *& value)
- { return gl_omap_iterator_next (&_state, reinterpret_cast<const void **>(&key), reinterpret_cast<const void **>(&value)); }
+ {
+ const void *next_key;
+ const void *next_value;
+ bool has_next = gl_omap_iterator_next (&_state, &next_key, &next_value);
+ if (has_next)
+ {
+ key = static_cast<KEYTYPE *>(next_key);
+ value = static_cast<VALUETYPE *>(next_value);
+ }
+ return has_next;
+ }
~iterator ()
{ gl_omap_iterator_free (&_state); }
diff --git a/lib/gl_oset.hh b/lib/gl_oset.hh
index 16da0dd2b3..b78ef52802 100644
--- a/lib/gl_oset.hh
+++ b/lib/gl_oset.hh
@@ -121,7 +121,13 @@ public:
/* If there is a next element, stores the next element in ELT, advances the
iterator and returns true. Otherwise, returns false. */
bool next (ELTYPE *& elt)
- { return gl_oset_iterator_next (&_state, reinterpret_cast<const void **>(&elt)); }
+ {
+ const void *next_elt;
+ bool has_next = gl_oset_iterator_next (&_state, &next_elt);
+ if (has_next)
+ elt = static_cast<ELTYPE *>(next_elt);
+ return has_next;
+ }
~iterator ()
{ gl_oset_iterator_free (&_state); }
diff --git a/lib/gl_set.hh b/lib/gl_set.hh
index 357e14175a..3b64bc5b1a 100644
--- a/lib/gl_set.hh
+++ b/lib/gl_set.hh
@@ -114,7 +114,13 @@ public:
/* If there is a next element, stores the next element in ELT, advances the
iterator and returns true. Otherwise, returns false. */
bool next (ELTYPE *& elt)
- { return gl_set_iterator_next (&_state, reinterpret_cast<const void **>(&elt)); }
+ {
+ const void *next_elt;
+ bool has_next = gl_set_iterator_next (&_state, &next_elt);
+ if (has_next)
+ elt = static_cast<ELTYPE *>(next_elt);
+ return has_next;
+ }
~iterator ()
{ gl_set_iterator_free (&_state); }