[or-cvs] Nobody was using the return values from smartlist_(set|del|...

Nick Mathewson nickm at seul.org
Fri Nov 12 21:14:08 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv9863/src/common

Modified Files:
	container.c container.h 
Log Message:
Nobody was using the return values from smartlist_(set|del|del_keeporder), so remove them.

Index: container.c
===================================================================
RCS file: /home/or/cvsroot/src/common/container.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- container.c	12 Nov 2004 20:41:52 -0000	1.5
+++ container.c	12 Nov 2004 21:14:05 -0000	1.6
@@ -172,57 +172,47 @@
   tor_assert(idx < sl->num_used);
   return sl->list[idx];
 }
-/** Return the number of items in sl.
- */
-int smartlist_len(const smartlist_t *sl)
-{
-  return sl->num_used;
-}
-#endif
-
 /** Change the value of the <b>idx</b>th element of sl to <b>val</b>; return the old
  * value of the <b>idx</b>th element.
  */
-void *smartlist_set(smartlist_t *sl, int idx, void *val)
+void smartlist_set(smartlist_t *sl, int idx, void *val)
 {
-  void *old;
   tor_assert(sl);
   tor_assert(idx>=0);
   tor_assert(idx < sl->num_used);
-  old = sl->list[idx];
   sl->list[idx] = val;
-  return old;
 }
+/** Return the number of items in sl.
+ */
+int smartlist_len(const smartlist_t *sl)
+{
+  return sl->num_used;
+}
+#endif
 
 /** Remove the <b>idx</b>th element of sl; if idx is not the last
  * element, swap the last element of sl into the <b>idx</b>th space.
  * Return the old value of the <b>idx</b>th element.
  */
-void *smartlist_del(smartlist_t *sl, int idx)
+void smartlist_del(smartlist_t *sl, int idx)
 {
-  void *old;
   tor_assert(sl);
   tor_assert(idx>=0);
   tor_assert(idx < sl->num_used);
-  old = sl->list[idx];
   sl->list[idx] = sl->list[--sl->num_used];
-  return old;
 }
 /** Remove the <b>idx</b>th element of sl; if idx is not the last element,
  * moving all subsequent elements back one space. Return the old value
  * of the <b>idx</b>th element.
  */
-void *smartlist_del_keeporder(smartlist_t *sl, int idx)
+void smartlist_del_keeporder(smartlist_t *sl, int idx)
 {
-  void *old;
   tor_assert(sl);
   tor_assert(idx>=0);
   tor_assert(idx < sl->num_used);
-  old = sl->list[idx];
   --sl->num_used;
   if (idx < sl->num_used)
     memmove(sl->list+idx, sl->list+idx+1, sizeof(void*)*(sl->num_used-idx));
-  return old;
 }
 /** Insert the value <b>val</b> as the new <b>idx</b>th element of
  * <b>sl</b>, moving all items previously at <b>idx</b> or later

Index: container.h
===================================================================
RCS file: /home/or/cvsroot/src/common/container.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- container.h	12 Nov 2004 20:41:52 -0000	1.4
+++ container.h	12 Nov 2004 21:14:05 -0000	1.5
@@ -36,14 +36,15 @@
 /* smartlist_choose() is defined in crypto.[ch] */
 #ifndef FAST_SMARTLIST
 void *smartlist_get(const smartlist_t *sl, int idx);
+void smartlist_set(smartlist_t *sl, int idx, void *val);
 int smartlist_len(const smartlist_t *sl);
 #else
 #define smartlist_get(sl,idx) ((sl)->list[(idx)])
+#define smartlist_set(sl,idx,val) ((sl)->list[(idx)] = val)
 #define smartlist_len(sl) ((sl)->num_used)
 #endif
-void *smartlist_set(smartlist_t *sl, int idx, void *val);
-void *smartlist_del(smartlist_t *sl, int idx);
-void *smartlist_del_keeporder(smartlist_t *sl, int idx);
+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);
 
 #define SPLIT_SKIP_SPACE   0x01



More information about the tor-commits mailing list