Let's take advantage of the abstract OsinfoLinkList and inherit from it. Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- osinfo/osinfo_devicelinklist.c | 13 ++++--------- osinfo/osinfo_devicelinklist.h | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/osinfo/osinfo_devicelinklist.c b/osinfo/osinfo_devicelinklist.c index 5f27392..d0efc55 100644 --- a/osinfo/osinfo_devicelinklist.c +++ b/osinfo/osinfo_devicelinklist.c @@ -27,7 +27,7 @@ #include <osinfo/osinfo.h> #include <glib/gi18n-lib.h> -G_DEFINE_TYPE(OsinfoDeviceLinkList, osinfo_devicelinklist, OSINFO_TYPE_LIST); +G_DEFINE_TYPE(OsinfoDeviceLinkList, osinfo_devicelinklist, OSINFO_TYPE_LINKLIST); #define OSINFO_DEVICELINKLIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OSINFO_TYPE_DEVICELINKLIST, OsinfoDeviceLinkListPrivate)) @@ -177,14 +177,9 @@ OsinfoDeviceList *osinfo_devicelinklist_get_devices(OsinfoDeviceLinkList *list, OsinfoFilter *filter) { OsinfoDeviceList *newList = osinfo_devicelist_new(); - int i; - for (i = 0; i < osinfo_list_get_length(OSINFO_LIST(list)); i++) { - OsinfoEntity *ent = osinfo_list_get_nth(OSINFO_LIST(list), i); - if (!filter || osinfo_filter_matches(filter, ent)) { - OsinfoDevice *dev = OSINFO_DEVICE(osinfo_link_get_target(OSINFO_LINK(ent))); - osinfo_list_add(OSINFO_LIST(newList), OSINFO_ENTITY(dev)); - } - } + osinfo_linklist_get_targets(OSINFO_LINKLIST(list), + filter, + OSINFO_LIST(newList)); return newList; } diff --git a/osinfo/osinfo_devicelinklist.h b/osinfo/osinfo_devicelinklist.h index 42691b1..f2816f9 100644 --- a/osinfo/osinfo_devicelinklist.h +++ b/osinfo/osinfo_devicelinklist.h @@ -48,7 +48,7 @@ typedef struct _OsinfoDeviceLinkListPrivate OsinfoDeviceLinkListPrivate; /* object */ struct _OsinfoDeviceLinkList { - OsinfoList parent_instance; + OsinfoLinkList parent_instance; /* public */ @@ -60,7 +60,7 @@ struct _OsinfoDeviceLinkList struct _OsinfoDeviceLinkListClass { /*< private >*/ - OsinfoListClass parent_class; + OsinfoLinkListClass parent_class; /* class members */ }; -- 2.19.1 _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo