[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Actually, use #defines for common case. Nothing to see here.
Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv26305/src/common
Modified Files:
container.h
Log Message:
Actually, use #defines for common case. Nothing to see here.
Index: container.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/container.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- container.h 18 Oct 2005 04:51:07 -0000 1.18
+++ container.h 18 Oct 2005 05:03:44 -0000 1.19
@@ -37,32 +37,33 @@
void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2);
void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2);
/* smartlist_choose() is defined in crypto.[ch] */
+#ifdef DEBUG_SMARTLIST
/** Return the number of items in sl.
*/
extern INLINE int smartlist_len(const smartlist_t *sl) {
-#ifdef DEBUG_SMARTLIST
tor_assert(sl);
-#endif
return (sl)->num_used;
}
/** Return the <b>idx</b>th element of sl.
*/
extern INLINE void *smartlist_get(const smartlist_t *sl, int idx) {
-#ifdef DEBUG_SMARTLIST
tor_assert(sl);
tor_assert(idx>=0);
tor_assert(sl->num_used < idx);
-#endif
return sl->list[idx];
}
extern INLINE void smartlist_set(smartlist_t *sl, int idx, void *val) {
-#ifdef DEBUG_SMARTLIST
tor_assert(sl);
tor_assert(idx>=0);
tor_assert(sl->num_used < idx);
-#endif
sl->list[idx] = val;
}
+#else
+#define smartlist_len(sl) ((sl)->num_used)
+#define smartlist_get(sl, idx) ((sl)->list[idx])
+#define smartlist_set(sl, idx, val) ((sl)->list[idx] = (val))
+#endif
+
void smartlist_del(smartlist_t *sl, int idx);
void smartlist_del_keeporder(smartlist_t *sl, int idx);
void smartlist_insert(smartlist_t *sl, int idx, void *val);