Categories:
.NET (357)
C (330)
C++ (184)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (2)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Struts (1)
Windows (1)
XHTML (173)
Other Resources:
You cant use dynamically-allocated memory after you free it?
You cant use dynamically-allocated memory after you free it?
✍: Guest
No. Some early documentation for malloc stated that the contents of freed memory were ``left undisturbed,'' but this ill-advised guarantee was never universal and is not required by the C Standard.
Few programmers would use the contents of freed memory deliberately, but it is easy to do so accidentally. Consider the following (correct) code for freeing a singly-linked list:
struct list *listp, *nextp;
for(listp = base; listp != NULL; listp = nextp) {
nextp = listp->next;
free(listp);
}
and notice what would happen if the more-obvious loop iteration expression listp = listp->next were used, without the temporary nextp pointer.
2016-04-04, 2154👍, 0💬
Popular Posts:
1. The basics first, please define the web in simple language? How is it connected with internet? Wh...
What is the benefit of using an enum rather than a #define constant? The use of an enumeration const...
What Are the Parameter Modes Supported by PL/SQL? - Oracle DBA FAQ - Creating Your Own PL/SQL Proced...
What's the difference between J2SDK 1.5 and J2SDK 5.0? There is no difference, Sun Microsystems just...
What is triple constraint triangle in project management ? Project Management triangle is depicted a...