]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
VG_(addToXA): return index in the array where the item was added.
authorJulian Seward <jseward@acm.org>
Tue, 27 Feb 2007 16:40:53 +0000 (16:40 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 27 Feb 2007 16:40:53 +0000 (16:40 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6619

coregrind/m_commandline.c
coregrind/m_xarray.c
include/pub_tool_xarray.h

index aa62a1ae1a0c86e5296f323e04d38347c8a6cc47..97a4eee76df374dc6b5d193957daad9ad31e298e 100644 (file)
@@ -45,7 +45,7 @@
 
 static void add_string ( XArray* /* of HChar* */xa, HChar* str )
 {
-   VG_(addToXA)( xa, (void*)(&str) );
+   (void) VG_(addToXA)( xa, (void*)(&str) );
 }
 
 
index 405f4f1fcaf0ff0daa11282df52f6b44dfd77de5..09dc628ee1f203938da95cae3881abeeb83a4f52 100644 (file)
@@ -104,7 +104,7 @@ inline void* VG_(indexXA) ( XArray* xao, Word n )
    return ((char*)xa->arr) + n * xa->elemSzB;
 }
 
-void VG_(addToXA) ( XArray* xao, void* elem )
+Int VG_(addToXA) ( XArray* xao, void* elem )
 {
    struct _XArray* xa = (struct _XArray*)xao;
    vg_assert(xa);
@@ -137,6 +137,7 @@ void VG_(addToXA) ( XArray* xao, void* elem )
                 elem, xa->elemSzB );
    xa->usedsizeE++;
    xa->sorted = False;
+   return xa->usedsizeE-1;
 }
 
 // Generic shell sort.  Like stdlib.h's qsort().
index bdb75c3dc67d5efce0591594d1a34fd0b21fb368..234be204f21d515c8b026f377720b2d50bd0abd0 100644 (file)
@@ -61,8 +61,10 @@ extern void VG_(deleteXA) ( XArray* );
    before making further queries with lookupXA. */
 extern void VG_(setCmpFnXA) ( XArray*, Word (*compar)(void*,void*) );
 
-/* Add an element to an XArray.  Element is copied into the XArray. */
-extern void VG_(addToXA) ( XArray*, void* elem );
+/* Add an element to an XArray.  Element is copied into the XArray.
+   Index at which it was added is returned.  Note this will be
+   invalidated if the array is later sortXA'd. */
+extern Int VG_(addToXA) ( XArray*, void* elem );
 
 /* Sort an XArray using its comparison function, if set; else bomb.
    Probably not a stable sort w.r.t. equal elements module cmpFn. */