]> granicus.if.org Git - transmission/commitdiff
(trunk libT) make tr_ptrArrayNth() an inline function
authorJordan Lee <jordan@transmissionbt.com>
Mon, 14 Mar 2011 14:09:41 +0000 (14:09 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Mon, 14 Mar 2011 14:09:41 +0000 (14:09 +0000)
libtransmission/ptrarray.c
libtransmission/ptrarray.h

index 2b6c8a8e6eb7077bd3931dbf1d2425fabec4522a..853c68582ad983aed4cd9a36d88a498e8d646c7e 100644 (file)
@@ -57,17 +57,6 @@ tr_ptrArrayPeek( tr_ptrArray * t,
     return t->items;
 }
 
-void*
-tr_ptrArrayNth( tr_ptrArray* t,
-                int          i )
-{
-    assert( t );
-    assert( i >= 0 );
-    assert( i < t->n_items );
-
-    return t->items[i];
-}
-
 int
 tr_ptrArrayInsert( tr_ptrArray * t,
                    void        * ptr,
index e154f2ea1c26934b946ada860d94d8f219a522e0..314a43ee5a60a4f81f0ec3adf9fdadffe7d9ece9 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef _TR_PTR_ARRAY_H_
 #define _TR_PTR_ARRAY_H_
 
+#include <assert.h>
+
 #include "transmission.h"
 
 /**
@@ -48,8 +50,15 @@ void tr_ptrArrayForeach( tr_ptrArray         * array,
 
 /** @brief Return the nth item in a tr_ptrArray
     @return the nth item in a tr_ptrArray */
-void*         tr_ptrArrayNth( tr_ptrArray   * array,
-                              int             nth );
+static inline void*
+tr_ptrArrayNth( tr_ptrArray * array, int i )
+{
+    assert( array );
+    assert( i >= 0 );
+    assert( i < array->n_items );
+
+    return array->items[i];
+}
 
 /** @brief Remove the last item from the array and return it
     @return the pointer that's been removed from the array