]> mj.ucw.cz Git - leo.git/commitdiff
osm.h: osm_ref_(head|tail)
authorMartin Mares <mj@ucw.cz>
Sun, 27 Mar 2022 15:04:24 +0000 (17:04 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 27 Mar 2022 15:04:24 +0000 (17:04 +0200)
osm.h

diff --git a/osm.h b/osm.h
index e7b81684bea39ff6a0c214f56d6832eeaf88448d..e9d18a01f745c9cebd74343c7cc90e89a05f2d89 100644 (file)
--- a/osm.h
+++ b/osm.h
@@ -107,6 +107,18 @@ void osm_ref_add(struct osm_object *parent, clist *list, struct osm_object *son,
 #define OSM_FOR_EACH_BEGIN(_type, _var, _list) CLIST_FOR_EACH(struct osm_ref *, _ref, _list) { _type _var = (_type) _ref->o;
 #define OSM_FOR_EACH_END }
 
+static inline struct osm_object *osm_ref_head(clist *list)
+{
+  struct osm_ref *r = clist_head(list);
+  return r ? r->o : NULL;
+}
+
+static inline struct osm_object *osm_ref_tail(clist *list)
+{
+  struct osm_ref *r = clist_tail(list);
+  return r ? r->o : NULL;
+}
+
 struct osm_node *osm_node_new(osm_id_t id);
 void osm_node_dump(struct osm_node *n);
 void osm_node_dump_all(void);