Use valgrind to determine memory leaks in your program.
And no, realloc won't clean up the memory. All it does is reallocate the memory. As an example, if you have a pointer bar that points to 20 structs of type foo and you realloc, you could change how many structs you have room for. So you could make bar point at 40 foos, or 100 foos. The trick is that realloc is expensive, because it always creates contiguous memory, so it would probably be better to just use a linked list, depending on what you're doing with it.
Yes, though, your code should (on a very limited level) work for freeing memory. You might want to error-test it, though:
You will, of course, need far more robust error testing than that if you want to use multi-dimensional arrays, or if you want to actually distribute your code.
Linux man pages about malloc: http://man.he.net/?topic=malloc§ion=all They're hard to interpret if you're not used to it, but you should be able to glean some information from it each time you look until you've got a good understanding.
cplusplus.com reference page: http://www.cplusplus.com/reference/cstdlib/malloc/ This has handy information in it, and although it's not really comprehensive, the other three sites should give you a good handle on the situation.
In the code you showed you allocated memory only for 20 items of type foo.
bar=malloc(sizeof(foo)*20);
You did not allocate memory for structure data member void *blabla;
If you would allocate memory for this data member you should also free this memory before freeing memory for an item of type foo.