/memcheck/tests/amd64-freebsd/Makefile.in
/memcheck/tests/amd64-freebsd/posix_fadvise
/memcheck/tests/amd64-freebsd/posix_fallocate
+/memcheck/tests/amd64-freebsd/reallocf
# /memcheck/tests/x86-freebsd
/memcheck/tests/x86-freebsd/*.stderr.diff
one which we know exists. */ \
return VG_REPLACE_FUNCTION_EZU(10010,VG_Z_LIBC_SONAME,malloc) \
(new_size); \
- if (new_size <= 0) { \
+ if (new_size == 0) { \
VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \
MALLOC_TRACE(" = 0\n"); \
- return NULL; \
+ return ptrV; \
} \
v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_realloc, ptrV, new_size ); \
MALLOC_TRACE(" = %p\n", v ); \
- if (v == NULL) \
+ if (v == NULL) {\
VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \
+ SET_ERRNO_ENOMEM; \
+ } \
MALLOC_TRACE(" = %p\n", v ); \
return v; \
}
posix_fadvise.vgtest \
posix_fallocate.vgtest \
posix_fadvise.stderr.exp \
- posix_fallocate.stderr.exp
+ posix_fallocate.stderr.exp \
+ reallocf.vgtest \
+ reallocf.stderr.out
check_PROGRAMS = \
- posix_fadvise posix_fallocate
+ posix_fadvise posix_fallocate reallocf
AM_CFLAGS += @FLAG_M64@
AM_CXXFLAGS += @FLAG_M64@
--- /dev/null
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include "../../memcheck.h"
+
+int main(void)
+{
+ int *pi = NULL;
+ VALGRIND_DO_LEAK_CHECK;
+ pi = reallocf(pi, 10*sizeof(int));
+ VALGRIND_DO_ADDED_LEAK_CHECK;
+ pi = reallocf(pi, 0);
+ VALGRIND_DO_CHANGED_LEAK_CHECK;
+ pi = NULL;
+ pi = realloc(pi, 10*sizeof(int));
+ VALGRIND_DO_ADDED_LEAK_CHECK;
+ errno = 0;
+ pi = reallocf(pi, 1UL << 49);
+ assert(!pi);
+ assert(errno == ENOMEM);
+ VALGRIND_DO_CHANGED_LEAK_CHECK;
+}
--- /dev/null
+
+All heap blocks were freed -- no leaks are possible
+
+LEAK SUMMARY:
+ definitely lost: 0 (+0) bytes in 0 (+0) blocks
+ indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+ possibly lost: 0 (+0) bytes in 0 (+0) blocks
+ still reachable: 40 (+40) bytes in 1 (+1) blocks
+ suppressed: 0 (+0) bytes in 0 (+0) blocks
+Reachable blocks (those to which a pointer was found) are not shown.
+To see them, rerun with: --leak-check=full --show-leak-kinds=all
+
+All heap blocks were freed -- no leaks are possible
+
+LEAK SUMMARY:
+ definitely lost: 0 (+0) bytes in 0 (+0) blocks
+ indirectly lost: 0 (+0) bytes in 0 (+0) blocks
+ possibly lost: 0 (+0) bytes in 0 (+0) blocks
+ still reachable: 40 (+0) bytes in 1 (+0) blocks
+ suppressed: 0 (+0) bytes in 0 (+0) blocks
+Reachable blocks (those to which a pointer was found) are not shown.
+To see them, rerun with: --leak-check=full --show-leak-kinds=all
+
+All heap blocks were freed -- no leaks are possible
+
+
+HEAP SUMMARY:
+ in use at exit: 0 bytes in 0 blocks
+ total heap usage: 3 allocs, 3 frees, 562,949,953,421,392 bytes allocated
+
+For a detailed leak analysis, rerun with: --leak-check=full
+
+For lists of detected and suppressed errors, rerun with: -s
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
--- /dev/null
+prog: reallocf