Nicholas Nethercote 3d12e0e9db Terminology change: previously in Memcheck we had the four states:
noaccess, writable, readable, other

Now they are:

   noaccess, undefined, defined, partdefined

As a result, the following names:

   make_writable, make_readable,
   check_writable, check_readable, check_defined

have become:

   make_mem_undefined, make_mem_defined,
   check_mem_is_addressable, check_mem_is_defined, check_value_is_defined

(and likewise for the upper-case versions for client request macros).
The old MAKE_* and CHECK_* macros still work for backwards compatibility.

This is much better, because the old names were subtly misleading.  For
example:

  - "readable" really meant "readable and writable".
  - "writable" really meant "writable and maybe readable, depending on how
    the read value is used".
  - "check_writable" really meant "check writable or readable"

The new names avoid these problems.

The recently-added macro which was called MAKE_DEFINED is now
MAKE_MEM_DEFINED_IF_ADDRESSABLE.

I also corrected the spelling of "addressable" in numerous places in
memcheck.h.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5802
2006-03-31 11:57:59 +00:00

40 lines
769 B
C

#include <stdio.h>
#include <stdlib.h>
#include "../memcheck.h"
int main1 ( void )
{
int xxx, i;
for (i = 0; i < 10; i++) VALGRIND_CHECK_VALUE_IS_DEFINED(xxx);
return 0;
}
int main ( void )
{
int i, sum, m;
char* aa = calloc(100,1);
sum = 0;
VALGRIND_CHECK_MEM_IS_DEFINED(aa,100);
m = VALGRIND_MAKE_MEM_UNDEFINED( &aa[49], 1 );
VALGRIND_CHECK_MEM_IS_ADDRESSABLE(aa,100);
printf("m_na: returned value is %d\n", m );
for (i = 0; i < 100; i++)
sum += aa[i];
printf("sum is %s\n", sum > 0 ? "positive" : "non-positive");
m = VALGRIND_DISCARD(m);
printf("m_rm: returned value is %d\n", m );
for (i = 0; i < 100; i++)
sum += aa[i];
printf("sum is %s\n", sum > 0 ? "positive" : "non-positive");
return 0;
}