When I run this code:
#include
typedef struct _Food
{
char name [128];
} Food;
int
main (int argc, char **argv)
{
Food *f
sizeof is a compile-time operation, so memory allocation won't change how it works.
free does not erase memory, it just marks the block as unused. Even if you allocate a few hundred megabytes of memory, your pointer may still not be overwritten (modern computers have lots of RAM). However, after you free memory, you can no longer depend on its value.
See if your development environment has a memory allocation debugging setting -- some have settings to overwrite blocks with something like 0xDEADBEEF when you free them.
Also, you may wish to adopt the habit of setting your pointer to NULL immediately after calling free (to help encourage your program to crash early and loudly).