如何为以下代码释放内存:我想将名称存储在下面给定结构结构标记的名称字段中,然后释放内存
SINT32 TestExample(void)
{
typedef struct tag
{
char *name;
} ST;
int i;
ST **p, **p1;
p = p1 = (ST **)calloc(1, 10 * sizeof(ST *));
for(i=0; i<10; i++)
{
p[0] = (ST *)calloc(1, 10 * sizeof(ST));
p[0]->name = (char *)malloc(20 * sizeof(char));
sprintf(p[0]->name, "Name_%d", i);
++p;
}
/* TO DO: free the memory allocated in previous block */
{
------------------------
}
p = NULL:
return 0;
}