Code:
int *a=NULL;

realloc(a, sizeof(int *));
a[0] = 1;
I got segmentation fault at a[0]=1. May I know why is this so? I'm planning to use realloc instead of malloc because *a is a buffer which will be placed in a FOR loop and its size will constantly change.

Any help will be much appreciated!

Lastly, is there any good performance analysis tools in Linux that can measure cache misses, disk read, etc occuring in the program that I created?