summaryrefslogtreecommitdiffstats
path: root/src/list.h
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-07-07 22:32:13 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2008-07-07 22:32:13 +0200
commite09fa6f39c889cbe327510eaa1523a413d5bcde2 (patch)
tree87c0f179dae28adf2d804fccb05c29044bba4c7f /src/list.h
parentb50843560aa4f2a6afdfdf0d190db909c3449278 (diff)
PhotoRec: add "/cmd device ext2_group,group_nr,search" to carve the corresponding ext2/ext3 group number
or "/cmd device ext2_inode,inode_nr,search" to carve the group holding the specified inode
Diffstat (limited to 'src/list.h')
-rw-r--r--src/list.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/list.h b/src/list.h
index 53e1ff6..4822b84 100644
--- a/src/list.h
+++ b/src/list.h
@@ -347,4 +347,23 @@ static inline void td_list_add_sorted(struct td_list_head *newe, struct td_list_
}
td_list_add_tail(newe, head);
}
+
+static inline int td_list_add_sorted_uniq(struct td_list_head *newe, struct td_list_head *head,
+ int (*compar)(const struct td_list_head *a, const struct td_list_head *b))
+{
+ struct td_list_head *pos;
+ td_list_for_each(pos, head)
+ {
+ const int res=compar(newe,pos);
+ if(res<0)
+ {
+ __td_list_add(newe, pos->prev, pos);
+ return 0;
+ }
+ else if(res==0)
+ return 1;
+ }
+ td_list_add_tail(newe, head);
+ return 0;
+}
#endif