mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-07 12:44:45 +00:00
is Rich Coe. Also, a minor mod to Makefile.install.am to handle tool names with dashes in. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7112
45 lines
626 B
C
45 lines
626 B
C
#include <stdlib.h>
|
|
|
|
typedef struct
|
|
{
|
|
int tracking;
|
|
unsigned long alignment;
|
|
} structure1;
|
|
|
|
void *fake_malloc(size_t length)
|
|
{
|
|
structure1 *pointer1 = 0;
|
|
|
|
pointer1 = malloc(sizeof(structure1) + length);
|
|
if(pointer1)
|
|
{
|
|
pointer1->tracking = 3;
|
|
pointer1++;
|
|
}
|
|
|
|
return pointer1;
|
|
}
|
|
|
|
void fake_free(void *pointer2)
|
|
{
|
|
structure1 *pointer3 = (structure1 *)pointer2;
|
|
|
|
if(pointer3)
|
|
{
|
|
pointer3--;
|
|
free(pointer3);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
void *pointer4 = 0;
|
|
|
|
pointer4 = fake_malloc(50);
|
|
fake_free(pointer4);
|
|
|
|
return 0;
|
|
} /* No leaks. */
|