controlled (rounding user malloc requests up to a multiple of 4).
Subsequent changes to memcheck made it more or less pointless, it is a
time waster in the malloc/free path, and nobody ever used it AFAIK.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3522
// greater than 8.
#define VG_MIN_MALLOC_SZB 8
-// Round-up size for --sloppy-malloc=yes.
-#define VG_SLOPPY_MALLOC_SZB 4
-
extern void* VG_(arena_malloc) ( ArenaId arena, SizeT nbytes );
extern void VG_(arena_free) ( ArenaId arena, void* ptr );
extern void* VG_(arena_calloc) ( ArenaId arena,
SizeT (*arena_payload_szB) (ArenaId aid, void* payload);
- Bool clo_sloppy_malloc;
Bool clo_trace_malloc;
};
/*--- Command line options ---*/
/*------------------------------------------------------------*/
-/* Round malloc sizes up to a multiple of VG_SLOPPY_MALLOC_SZB bytes?
- default: NO
- Nb: the allocator always rounds blocks up to a multiple of
- VG_MIN_MALLOC_SZB. VG_(clo_sloppy_malloc) is relevant eg. for
- Memcheck, which will be byte-precise with addressability maps on its
- malloc allocations unless --sloppy-malloc=yes. */
-Bool VG_(clo_sloppy_malloc) = False;
+/* Nb: the allocator always rounds blocks up to a multiple of
+ VG_MIN_MALLOC_SZB.
+*/
/* DEBUG: print malloc details? default: NO */
Bool VG_(clo_trace_malloc) = False;
}
}
- else VG_BOOL_CLO(arg, "--sloppy-malloc", VG_(clo_sloppy_malloc))
else VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc))
else
return False;
void VG_(replacement_malloc_print_usage)(void)
{
VG_(printf)(
-" --sloppy-malloc=no|yes round malloc sizes to multiple of %d? [no]\n"
" --alignment=<number> set minimum alignment of allocations [%d]\n",
- VG_SLOPPY_MALLOC_SZB, VG_MIN_MALLOC_SZB
+ VG_MIN_MALLOC_SZB
);
}
if (info.clo_trace_malloc) \
internal_printf(format, ## args )
-#define MAYBE_SLOPPIFY(n) \
- if (info.clo_sloppy_malloc) { \
- n = (n+(VG_SLOPPY_MALLOC_SZB-1)) & ~(VG_SLOPPY_MALLOC_SZB-1); \
- }
-
-
/* Below are new versions of malloc, __builtin_new, free,
__builtin_delete, calloc, realloc, memalign, and friends.
void* v; \
\
MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \
- MAYBE_SLOPPIFY(n); \
if (!init_done) init(); \
\
v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \
void* v; \
\
MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \
- MAYBE_SLOPPIFY(n); \
if (!init_done) init(); \
\
v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \
void* v; \
\
MALLOC_TRACE("calloc(%llu,%llu)", (ULong)nmemb, (ULong)size ); \
- MAYBE_SLOPPIFY(size); \
\
if (!init_done) init(); \
v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_calloc, nmemb, size ); \
void* v; \
\
MALLOC_TRACE("realloc(%p,%llu)", ptrV, (ULong)new_size ); \
- MAYBE_SLOPPIFY(new_size); \
\
if (ptrV == NULL) \
/* We need to call a malloc-like function; so let's use \
\
MALLOC_TRACE("memalign(al %llu, size %llu)", \
(ULong)alignment, (ULong)n ); \
- MAYBE_SLOPPIFY(n); \
\
/* Round up to minimum alignment if necessary. */ \
if (alignment < VG_MIN_MALLOC_SZB) \
info->tl___builtin_vec_delete = VG_(tdict).malloc___builtin_vec_delete;
info->arena_payload_szB = VG_(arena_payload_szB);
-
- info->clo_sloppy_malloc = VG_(clo_sloppy_malloc);
info->clo_trace_malloc = VG_(clo_trace_malloc);
SET_CLREQ_RETVAL( tid, 0 ); /* return value is meaningless */
and 4096 inclusive, and must be a power of two.</para>
</listitem>
- <listitem>
- <para><computeroutput>--sloppy-malloc=no</computeroutput>
- [default]</para>
- <para><computeroutput>--sloppy-malloc=yes</computeroutput></para>
- <para>When enabled, all requests for malloc/calloc are
- rounded up to a whole number of machine words -- in other
- words, made divisible by 4. For example, a request for 17
- bytes of space would result in a 20-byte area being made
- available. This works around bugs in sloppy libraries which
- assume that they can safely rely on malloc/calloc requests
- being rounded up in this fashion. Without the workaround,
- these libraries tend to generate large numbers of errors when
- they access the ends of these areas.</para>
-
- <para>Valgrind snapshots dated 17 Feb 2002 and later are
- cleverer about this problem, and you should no longer need to
- use this flag. To put it bluntly, if you do need to use this
- flag, your program violates the ANSI C semantics defined for
- <computeroutput>malloc</computeroutput> and
- <computeroutput>free</computeroutput>, even if it appears to
- work correctly, and you should fix it, at least if you hope
- for maximum portability.</para>
- </listitem>
</itemizedlist>
</sect2>
The tool should call the functions in the appropriate places to give
control over these aspects of Valgrind's version of malloc(). */
-/* Round malloc sizes upwards to integral number of words? default: NO */
-extern Bool VG_(clo_sloppy_malloc);
/* DEBUG: print malloc details? default: NO */
extern Bool VG_(clo_trace_malloc);
/* Minimum alignment in functions that don't specify alignment explicitly.