src/inc/common.h 1.150
1.150 2009/05/10 02:09:15 markd
convert slAddHead to an inline function, bitten one too many times by it being a macro
Index: src/inc/common.h
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/inc/common.h,v
retrieving revision 1.149
retrieving revision 1.150
diff -b -B -U 4 -r1.149 -r1.150
--- src/inc/common.h 14 Apr 2009 08:43:02 -0000 1.149
+++ src/inc/common.h 10 May 2009 02:09:15 -0000 1.150
@@ -345,21 +345,29 @@
int slIxFromElement(void *list, void *el);
/* Return index of el in list. Returns -1 if not on list. */
-void slSafeAddHead(void *listPt, void *node);
+INLINE void slAddHead(void *listPt, void *node)
/* Add new node to start of list.
* Usage:
- * slSafeAddHead(&list, node);
+ * slAddHead(&list, node);
* where list and nodes are both pointers to structure
* that begin with a next pointer.
*/
-
-/* Add new node to start of list, this macro is faster
- * than slSafeAddHead, but has standard macro restriction
- * on what can be safely passed as arguments. */
-#define slAddHead(listPt, node) \
- ((node)->next = *(listPt), *(listPt) = (node))
+{
+struct slList **ppt = (struct slList **)listPt;
+struct slList *n = (struct slList *)node;
+n->next = *ppt;
+*ppt = n;
+}
+
+INLINE void slSafeAddHead(void *listPt, void *node)
+/* Add new node to start of list. Now that slAddHead is an inline instead of
+ * a macro, this function is obsolete.
+ */
+{
+slAddHead(listPt, node);
+}
void slAddTail(void *listPt, void *node);
/* Add new node to tail of list.
* Usage: