ruby-changes:14809
From: akr <ko1@a...>
Date: Mon, 15 Feb 2010 22:31:23 +0900 (JST)
Subject: [ruby-changes:14809] Ruby:r26671 (trunk): * ext/zlib/zlib.c (zlib_mem_alloc): suppress valgrind warnings.
akr 2010-02-15 22:26:51 +0900 (Mon, 15 Feb 2010) New Revision: 26671 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26671 Log: * ext/zlib/zlib.c (zlib_mem_alloc): suppress valgrind warnings. http://www.zlib.net/zlib_faq.html#faq36 Modified files: trunk/ChangeLog trunk/ext/zlib/zlib.c Index: ChangeLog =================================================================== --- ChangeLog (revision 26670) +++ ChangeLog (revision 26671) @@ -1,3 +1,8 @@ +Mon Feb 15 22:25:16 2010 Tanaka Akira <akr@f...> + + * ext/zlib/zlib.c (zlib_mem_alloc): suppress valgrind warnings. + http://www.zlib.net/zlib_faq.html#faq36 + Mon Feb 15 22:18:49 2010 Tanaka Akira <akr@f...> * time.c (time_add): propagate fixed time offset. Index: ext/zlib/zlib.c =================================================================== --- ext/zlib/zlib.c (revision 26670) +++ ext/zlib/zlib.c (revision 26671) @@ -11,6 +11,19 @@ #include <time.h> #include <ruby/encoding.h> +#ifdef HAVE_VALGRIND_MEMCHECK_H +# include <valgrind/memcheck.h> +# ifndef VALGRIND_MAKE_MEM_DEFINED +# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE(p, n) +# endif +# ifndef VALGRIND_MAKE_MEM_UNDEFINED +# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE(p, n) +# endif +#else +# define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */ +# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) /* empty */ +#endif + #define RUBY_ZLIB_VERSION "0.6.0" @@ -436,7 +449,13 @@ static voidpf zlib_mem_alloc(voidpf opaque, uInt items, uInt size) { - return xmalloc(items * size); + voidpf p = xmalloc(items * size); + /* zlib FAQ: Valgrind (or some similar memory access checker) says that + deflate is performing a conditional jump that depends on an + uninitialized value. Isn't that a bug? + http://www.zlib.net/zlib_faq.html#faq36 */ + VALGRIND_MAKE_MEM_DEFINED(p, items * size); + return p; } static void -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/