Skip to content

Commit d3d7987

Browse files
committed
who knew the previous implementation was actually smart
1 parent b55e9cb commit d3d7987

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

coregrind/m_replacemalloc/vg_replace_malloc.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,34 +2094,37 @@ extern int * __error(void) __attribute__((weak));
20942094

20952095
#define WITH_OPTIONS_INIT_FLAG 1
20962096

2097-
#define ZONEMEMALIGN_WITH_OPTIONS(soname, fnname) \
2098-
ZONEMEMALIGN(soname, fnname); \
2099-
\
2097+
#define ZONEMEMALIGN_WITH_OPTIONS(soname, fnname) \
2098+
ZONEMEMALIGN(soname, fnname); \
2099+
\
21002100
void* VG_REPLACE_FUNCTION_EZU(10101, soname, fnname)(void* zone, SizeT alignment, SizeT n, UWord options); \
21012101
void* VG_REPLACE_FUNCTION_EZU(10101, soname, fnname)(void* zone, SizeT alignment, SizeT n, UWord options) \
2102-
{ \
2103-
void* v = VG_REPLACE_FUNCTION_EZU(10100,soname,fnname)(zone, alignment, n); \
2104-
if (v != NULL && (options & WITH_OPTIONS_INIT_FLAG) != 0) { \
2105-
for (SizeT i = 0; i < n; i += 1) { \
2106-
((UChar*)v)[i] = 0; \
2107-
} \
2108-
} \
2109-
return v; \
2102+
{ \
2103+
void *v; \
2104+
if (alignment != 0) { \
2105+
v = VG_REPLACE_FUNCTION_EZU(10100,soname,fnname)(zone, alignment, n); \
2106+
if (v != NULL && (options & WITH_OPTIONS_INIT_FLAG) != 0) { \
2107+
for (SizeT i = 0; i < n; i += 1) { \
2108+
((UChar*)v)[i] = 0; \
2109+
} \
2110+
} \
2111+
} else { \
2112+
if ((options & WITH_OPTIONS_INIT_FLAG) == 0) { \
2113+
v = (void*)VALGRIND_NON_SIMD_CALL1(info.tl_malloc, n); \
2114+
} else { \
2115+
v = (void*)VALGRIND_NON_SIMD_CALL2(info.tl_calloc, 0x1, n); \
2116+
} \
2117+
} \
2118+
return v; \
21102119
}
21112120

2112-
#define ZONEMEMALIGN_TYPE_WITH_OPTIONS(soname, fnname) \
2113-
ZONEMEMALIGN(soname, fnname); \
2114-
\
2121+
#define ZONEMEMALIGN_TYPE_WITH_OPTIONS(soname, fnname) \
2122+
ZONEMEMALIGN_WITH_OPTIONS(soname, fnname); \
2123+
\
21152124
void* VG_REPLACE_FUNCTION_EZU(10102, soname, fnname)(void* zone, SizeT alignment, SizeT n, UWord type, UWord options); \
21162125
void* VG_REPLACE_FUNCTION_EZU(10102, soname, fnname)(void* zone, SizeT alignment, SizeT n, UWord type, UWord options) \
2117-
{ \
2118-
void* v = VG_REPLACE_FUNCTION_EZU(10100,soname,fnname)(zone, alignment, n); \
2119-
if (v != NULL && (options & WITH_OPTIONS_INIT_FLAG) != 0) { \
2120-
for (SizeT i = 0; i < n; i += 1) { \
2121-
((UChar*)v)[i] = 0; \
2122-
} \
2123-
} \
2124-
return v; \
2126+
{ \
2127+
return VG_REPLACE_FUNCTION_EZU(10101,soname,fnname)(zone, alignment, n, options); \
21252128
}
21262129

21272130
#endif

0 commit comments

Comments
 (0)