]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a method to get the contents of an XArray so we can index in
authorJulian Seward <jseward@acm.org>
Wed, 5 May 2010 09:23:41 +0000 (09:23 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 5 May 2010 09:23:41 +0000 (09:23 +0000)
it really fast, or iterate over it.  This is dangerous and breaks
the nice abstraction (sigh).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11122

coregrind/m_xarray.c
include/pub_tool_xarray.h

index 9b2baee40e8ae2e85c400bae0b8b8f243ab103c6..cdcf978615128e3dd5906ab1f7dc12a599be9809 100644 (file)
@@ -306,6 +306,16 @@ void VG_(dropHeadXA) ( XArray* xao, Word n )
    xa->usedsizeE -= n;
 }
 
+void VG_(getContentsXA_UNSAFE)( XArray* xao,
+                                /*OUT*/void** ctsP,
+                                /*OUT*/Word* usedP )
+{
+   struct _XArray* xa = (struct _XArray*)xao;
+   vg_assert(xa);
+   *ctsP  = (void*)xa->arr;
+   *usedP = xa->usedsizeE;
+}
+
 /* --------- Printeffery --------- */
 
 static void add_char_to_XA ( HChar c, void* opaque )
index 8d2d32b4ebc6b59f142b869dd76ad1972f0eff88..cd1b02e43bd0c619137d27210f3634450f092864 100644 (file)
@@ -125,6 +125,16 @@ extern void VG_(dropHeadXA) ( XArray*, Word );
    is NULL, in which case the parent's cost-center is used. */
 extern XArray* VG_(cloneXA)( HChar* cc, XArray* xa );
 
+/* Get the raw array and size so callers can index it really fast.
+   This is dangerous in the sense that there's no range or
+   anything-else checking.  It's also dangerous in that if
+   VG_(addToXA) is used, the contents may be re-located without
+   warning, hence making the contents address returned here
+   invalid. */
+extern void VG_(getContentsXA_UNSAFE)( XArray* sr,
+                                       /*OUT*/void** ctsP,
+                                       /*OUT*/Word*  usedP );
+
 /* Convenience function: printf into an XArray of HChar, adding stuff
    at the end.  This is very convenient for concocting arbitrary
    length printf output in an XArray.  Note that the resulting string