~bkerensa/ubuntu/raring/valgrind/merge-from-deb

« back to all changes in this revision

Viewing changes to exp-omega/tests/shadow1.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrés Roldán
  • Date: 2008-06-13 02:31:40 UTC
  • mto: (1.4.1 upstream) (2.2.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: james.westby@ubuntu.com-20080613023140-iwk33rz9rhvfkr96
Import upstream version 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
 
 
3
typedef struct
 
4
{
 
5
  int tracking;
 
6
  unsigned long alignment;
 
7
} structure1;
 
8
 
 
9
void *fake_malloc(size_t length)
 
10
{
 
11
  structure1 *pointer1 = 0;
 
12
 
 
13
  pointer1 = malloc(sizeof(structure1) + length);
 
14
  if(pointer1)
 
15
  {
 
16
    pointer1->tracking = 3;
 
17
    pointer1++;
 
18
  }
 
19
  
 
20
  return pointer1;
 
21
}
 
22
 
 
23
void fake_free(void *pointer2)
 
24
{
 
25
  structure1 *pointer3 = (structure1 *)pointer2;
 
26
 
 
27
  if(pointer3)
 
28
  {
 
29
    pointer3--;
 
30
    free(pointer3);
 
31
  }
 
32
 
 
33
  return;
 
34
}
 
35
 
 
36
int main(int argc, char *argv[])
 
37
{
 
38
  void *pointer4 = 0;
 
39
 
 
40
  pointer4 = fake_malloc(50);
 
41
  fake_free(pointer4);
 
42
 
 
43
  return 0;
 
44
}                           /* No leaks. */