diff options
Diffstat (limited to 'dbus/dbus-list.c')
| -rw-r--r-- | dbus/dbus-list.c | 33 | 
1 files changed, 28 insertions, 5 deletions
diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index 235ed275..5d2bcd42 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -454,20 +454,43 @@ _dbus_list_remove_last (DBusList **list,  {    DBusList *link; +  link = _dbus_list_find_last (list, data); +  if (link) +    { +      _dbus_list_remove_link (list, link); +      return TRUE; +    } +  else +    return FALSE; +} + +/** + * Finds a value in the list. Returns the last link + * with value equal to the given data pointer. + * This is a linear-time operation. + * Returns #NULL if no value found that matches. + * + * @param list address of the list head. + * @param data the value to find. + * @returns the link if found + */ +DBusList* +_dbus_list_find_last (DBusList **list, +                      void      *data) +{ +  DBusList *link; +    link = _dbus_list_get_last_link (list);    while (link != NULL)      {        if (link->data == data) -        { -          _dbus_list_remove_link (list, link); -          return TRUE; -        } +        return link;        link = _dbus_list_get_prev_link (list, link);      } -  return FALSE; +  return NULL;  }  /**  | 
