]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
* intercept stpcpy
authorJulian Seward <jseward@acm.org>
Tue, 21 Oct 2008 23:11:38 +0000 (23:11 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 21 Oct 2008 23:11:38 +0000 (23:11 +0000)
* reorder declarations to make them be the same as in mc_replace_strmem.c.

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

exp-ptrcheck/h_intercepts.c

index 8b95cb5aa25627002f538a0143e05961936cf1df..48819d4c6f2a9e7d0102028141a4d7c386016061 100644 (file)
@@ -41,7 +41,8 @@
 
 
 /* The following intercepts are copied verbatim from
-   memcheck/mc_replace_strmem.c. */
+   memcheck/mc_replace_strmem.c.  If you copy more in, please keep
+   them in the same order as in mc_replace_strmem.c. */
 
 /* --------- Some handy Z-encoded names. --------- */
 
 
 
 
+// Note that this replacement often doesn't get used because gcc inlines
+// calls to strlen() with its own built-in version.  This can be very
+// confusing if you aren't expecting it.  Other small functions in this file
+// may also be inline by gcc.
+#define STRLEN(soname, fnname) \
+   SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ); \
+   SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ) \
+   { \
+      SizeT i = 0; \
+      while (str[i] != 0) i++; \
+      return i; \
+   }
+
+STRLEN(m_libc_soname,          strlen)
+STRLEN(m_ld_linux_so_2,        strlen)
+STRLEN(m_ld_linux_x86_64_so_2, strlen)
+STRLEN(m_ld_so_1,              strlen)
+
+
 #define STRCMP(soname, fnname) \
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
           ( const char* s1, const char* s2 ); \
@@ -93,24 +113,6 @@ STRCMP(m_ld_linux_x86_64_so_2, strcmp)
 STRCMP(m_ld64_so_1,            strcmp)
 
 
-// Note that this replacement often doesn't get used because gcc inlines
-// calls to strlen() with its own built-in version.  This can be very
-// confusing if you aren't expecting it.  Other small functions in this file
-// may also be inline by gcc.
-#define STRLEN(soname, fnname) \
-   SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ); \
-   SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname)( const char* str ) \
-   { \
-      SizeT i = 0; \
-      while (str[i] != 0) i++; \
-      return i; \
-   }
-
-STRLEN(m_libc_soname,          strlen)
-STRLEN(m_ld_linux_so_2,        strlen)
-STRLEN(m_ld_linux_x86_64_so_2, strlen)
-
-
 #define MEMCPY(soname, fnname) \
    void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
             ( void *dst, const void *src, SizeT sz ); \
@@ -158,6 +160,23 @@ MEMCPY(m_ld_so_1,     memcpy) /* ld.so.1 */
 MEMCPY(m_ld64_so_1,   memcpy) /* ld64.so.1 */
 
 
+/* Copy SRC to DEST, returning the address of the terminating '\0' in
+   DEST. (minor variant of strcpy) */
+#define STPCPY(soname, fnname) \
+   char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( char* dst, const char* src ); \
+   char* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( char* dst, const char* src ) \
+   { \
+      while (*src) *dst++ = *src++; \
+      *dst = 0; \
+      \
+      return dst; \
+   }
+
+STPCPY(m_libc_soname,         stpcpy)
+STPCPY(m_ld_linux_so_2,        stpcpy)
+STPCPY(m_ld_linux_x86_64_so_2, stpcpy)
+
+
 /*--------------------------------------------------------------------*/
 /*--- end                                          pc_intercepts.c ---*/
 /*--------------------------------------------------------------------*/