<p>I am trying to use a malloc hook to create a custom function my_malloc(). In my main program when I call malloc() I want it to call my_malloc() can someone please give me an example on how to do this in C</p>

```
```
#undef malloc
#define malloc my_malloc
```
```
Just put that at the top of any of the files you need to do it for.