Moved VG_(strdup)() and VG_(arena_strdup)() into m_mallocfree.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3878 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/core.h b/coregrind/core.h
index 1774511..2f5a46a 100644
--- a/coregrind/core.h
+++ b/coregrind/core.h
@@ -131,9 +131,6 @@
Exports of vg_mylibc.c
------------------------------------------------------------------ */
-/* Tools use VG_(strdup)() which doesn't expose ArenaId */
-extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s);
-
extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout);
diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c
index 235c923..e1f1e1a 100644
--- a/coregrind/m_mallocfree.c
+++ b/coregrind/m_mallocfree.c
@@ -1263,6 +1263,25 @@
}
+/* Inline just for the wrapper VG_(strdup) below */
+__inline__ Char* VG_(arena_strdup) ( ArenaId aid, const Char* s )
+{
+ Int i;
+ Int len;
+ Char* res;
+
+ if (s == NULL)
+ return NULL;
+
+ len = VG_(strlen)(s) + 1;
+ res = VG_(arena_malloc) (aid, len);
+
+ for (i = 0; i < len; i++)
+ res[i] = s[i];
+ return res;
+}
+
+
/*------------------------------------------------------------*/
/*--- Tool-visible functions. ---*/
/*------------------------------------------------------------*/
@@ -1289,6 +1308,11 @@
return VG_(arena_realloc) ( VG_AR_TOOL, ptr, size );
}
+Char* VG_(strdup) ( const Char* s )
+{
+ return VG_(arena_strdup) ( VG_AR_TOOL, s );
+}
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
diff --git a/coregrind/pub_core_mallocfree.h b/coregrind/pub_core_mallocfree.h
index f6d0ea1..b5b7ec2 100644
--- a/coregrind/pub_core_mallocfree.h
+++ b/coregrind/pub_core_mallocfree.h
@@ -75,6 +75,7 @@
extern void* VG_(arena_realloc) ( ArenaId arena, void* ptr, SizeT size );
extern void* VG_(arena_memalign)( ArenaId aid, SizeT req_alignB,
SizeT req_pszB );
+extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s);
/* Sets the size of the redzones at the start and end of heap blocks. This
must be called before any of VG_(malloc) and friends are called. */
diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c
index 147ecd5..55ed2de 100644
--- a/coregrind/vg_mylibc.c
+++ b/coregrind/vg_mylibc.c
@@ -209,34 +209,6 @@
/* ---------------------------------------------------------------------
- strdup()
- ------------------------------------------------------------------ */
-
-/* Inline just for the wrapper VG_(strdup) below */
-__inline__ Char* VG_(arena_strdup) ( ArenaId aid, const Char* s )
-{
- Int i;
- Int len;
- Char* res;
-
- if (s == NULL)
- return NULL;
-
- len = VG_(strlen)(s) + 1;
- res = VG_(arena_malloc) (aid, len);
-
- for (i = 0; i < len; i++)
- res[i] = s[i];
- return res;
-}
-
-/* Wrapper to avoid exposing tools to ArenaId's */
-Char* VG_(strdup) ( const Char* s )
-{
- return VG_(arena_strdup) ( VG_AR_TOOL, s );
-}
-
-/* ---------------------------------------------------------------------
Misc functions looking for a proper home.
------------------------------------------------------------------ */
diff --git a/include/pub_tool_libcbase.h b/include/pub_tool_libcbase.h
index b60c891..e96a8c5 100644
--- a/include/pub_tool_libcbase.h
+++ b/include/pub_tool_libcbase.h
@@ -64,7 +64,6 @@
extern Char* VG_(strstr) ( const Char* haystack, Char* needle );
extern Char* VG_(strchr) ( const Char* s, Char c );
extern Char* VG_(strrchr) ( const Char* s, Char c );
-extern Char* VG_(strdup) ( const Char* s);
/* Like strcmp() and strncmp(), but stop comparing at any whitespace. */
extern Int VG_(strcmp_ws) ( const Char* s1, const Char* s2 );
diff --git a/include/pub_tool_mallocfree.h b/include/pub_tool_mallocfree.h
index d89edaf..1fbf9f5 100644
--- a/include/pub_tool_mallocfree.h
+++ b/include/pub_tool_mallocfree.h
@@ -37,6 +37,7 @@
extern void VG_(free) ( void* p );
extern void* VG_(calloc) ( SizeT n, SizeT bytes_per_elem );
extern void* VG_(realloc) ( void* p, SizeT size );
+extern Char* VG_(strdup) ( const Char* s );
#endif // __PUB_TOOL_MALLOCFREE_H