[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Convenience function to do a strcmp on each member of a sma...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] Convenience function to do a strcmp on each member of a sma...
- From: nickm@seul.org (Nick Mathewson)
- Date: Mon, 16 Aug 2004 16:46:04 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Mon, 16 Aug 2004 16:46:15 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv18463/src/common
Modified Files:
util.c util.h
Log Message:
Convenience function to do a strcmp on each member of a smartlist of strings
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- util.c 9 Aug 2004 04:28:25 -0000 1.123
+++ util.c 16 Aug 2004 20:46:00 -0000 1.124
@@ -360,6 +360,14 @@
return 0;
}
+int smartlist_string_isin(const smartlist_t *sl, const char *element) {
+ int i;
+ for(i=0; i < sl->num_used; i++)
+ if(strcmp((const char*)sl->list[i],element)==0)
+ return 1;
+ return 0;
+}
+
/** Return true iff some element E of sl2 has smartlist_isin(sl1,E).
*/
int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2) {
Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- util.h 9 Aug 2004 04:28:25 -0000 1.80
+++ util.h 16 Aug 2004 20:46:00 -0000 1.81
@@ -147,6 +147,7 @@
void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2);
void smartlist_remove(smartlist_t *sl, void *element);
int smartlist_isin(const smartlist_t *sl, void *element);
+int smartlist_string_isin(const smartlist_t *sl, const char *element);
int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2);
void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2);
void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2);