मैं निम्नलिखित है struct
:क्या मुझे स्थानीय चर मुक्त करने की आवश्यकता है?
typedef struct cell Cell;
struct cell {
int value;
int *nextcell;
};
और मैं एक लिंक्ड सूची मुक्त करने के लिए निम्न कार्य हो:
void freelist(Cell *beginning)
{
Cell *thisCell = beginning;
Cell *NextCell = beginning->nextcell;
while (thisCell != NULL)
{
NextCell = thisCell->nextcell;
free(thisCell);
thisCell = NextCell;
}
/* Here comes my question. Do I need to free the following variables? */
free(beginnig);
free(thisCell);
free(NextCell);
}
आप वैरिएबल मुक्त नहीं करते हैं, आप मुफ्त मेमोरी। अंगूठे का नियम: एक मुफ्त प्रति मॉलोक (या realloc)। –