|
From: <sv...@va...> - 2007-02-27 16:40:58
|
Author: sewardj
Date: 2007-02-27 16:40:53 +0000 (Tue, 27 Feb 2007)
New Revision: 6619
Log:
VG_(addToXA): return index in the array where the item was added.
Modified:
trunk/coregrind/m_commandline.c
trunk/coregrind/m_xarray.c
trunk/include/pub_tool_xarray.h
Modified: trunk/coregrind/m_commandline.c
===================================================================
--- trunk/coregrind/m_commandline.c 2007-02-26 00:16:09 UTC (rev 6618)
+++ trunk/coregrind/m_commandline.c 2007-02-27 16:40:53 UTC (rev 6619)
@@ -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) );
}
Modified: trunk/coregrind/m_xarray.c
===================================================================
--- trunk/coregrind/m_xarray.c 2007-02-26 00:16:09 UTC (rev 6618)
+++ trunk/coregrind/m_xarray.c 2007-02-27 16:40:53 UTC (rev 6619)
@@ -104,7 +104,7 @@
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 @@
elem, xa->elemSzB );
xa->usedsizeE++;
xa->sorted = False;
+ return xa->usedsizeE-1;
}
// Generic shell sort. Like stdlib.h's qsort().
Modified: trunk/include/pub_tool_xarray.h
===================================================================
--- trunk/include/pub_tool_xarray.h 2007-02-26 00:16:09 UTC (rev 6618)
+++ trunk/include/pub_tool_xarray.h 2007-02-27 16:40:53 UTC (rev 6619)
@@ -61,8 +61,10 @@
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. */
|