Re: [i3] [PATCH] Improved i3bar hide mode behavior (In my point of view)
- From: Michael Stapelberg <michael@xxxxxxxx>
- To: Discussions/Questions about the i3 window manager <i3-discuss@xxxxxxxxxxxxx>
- Date: Thu, 26 Jul 2012 13:14:11 +0200
Hi Mateusz,
Quoting Mateusz Loskot (2012-07-13 20:06:58)
1) You are not using FREE(last_urgent_ws);, but free(last_urgent_ws) in
line 1489, which is unsafe (it is not guaranteed that last_urgent_ws
is != NULL).
There is no such guarantee needed for free() as per the C99 Standard:
7.20.3.2 The free function
2 The free function causes the space pointed to by ptr to be
deallocated, that is, made
available for further allocation. If ptr is a null pointer, no action occurs.
I think you misunderstood me. What FREE does is it sets the pointer to
NULL after calling free(). Therefore, the following code works fine:
FREE(last_urgent_ws);
// …things happen here, and much later:
FREE(last_urgent_ws);
While the following is not:
free(last_urgent_ws);
// …things happen here, and much later:
free(last_urgent_ws); // points to an old memory location
Best regards,
Michael
Other related posts: