[Pcsclite-cvs-commit] r4561 - in /trunk/PCSC/src: simclist.c simclist.h
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Thu Nov 19 09:05:38 UTC 2009
Author: rousseau
Date: Thu Nov 19 09:05:27 2009
New Revision: 4561
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4561
Log:
add list_delete() "expunge the first found given element from the list"
Modified:
trunk/PCSC/src/simclist.c
trunk/PCSC/src/simclist.h
Modified: trunk/PCSC/src/simclist.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/simclist.c?rev=4561&op=diff
==============================================================================
--- trunk/PCSC/src/simclist.c (original)
+++ trunk/PCSC/src/simclist.c Thu Nov 19 09:05:27 2009
@@ -441,6 +441,22 @@
assert(list_repOk(l));
return 1;
+}
+
+int list_delete(list_t *restrict l, const void *data) {
+ int pos, r;
+
+ pos = list_locate(l, data);
+ if (pos < 0)
+ return pos;
+
+ r = list_delete_at(l, pos);
+ if (r < 0)
+ return r;
+
+ assert(list_repOk(l));
+
+ return 0;
}
int list_delete_at(list_t *restrict l, unsigned int pos) {
Modified: trunk/PCSC/src/simclist.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/simclist.h?rev=4561&op=diff
==============================================================================
--- trunk/PCSC/src/simclist.h (original)
+++ trunk/PCSC/src/simclist.h Thu Nov 19 09:05:27 2009
@@ -427,6 +427,22 @@
int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
/**
+ * expunge the first found given element from the list.
+ *
+ * @warning Requires a comparator function to be set for the list.
+ *
+ * Inspects the given list looking for the given element; if the element
+ * is found, it is removed. Only the first occurence is removed.
+ * Elements are inspected comparing references if a comparator has not been
+ * set. Otherwise, the comparator is used to find the element.
+ *
+ * @param l list to operate
+ * @param data reference of the element to search for
+ * @return 0 on success. Negative value on failure
+ */
+int list_delete(list_t *restrict l, const void *data);
+
+/**
* expunge an element at a given position from the list.
*
* @param l list to operate
More information about the Pcsclite-cvs-commit
mailing list