Recommit 1.259, but now with TAILQ_FOREACH_SAFE.
From and OK okan@ Original commit message: Plug two memory leaks. Also get rid of a variable that is no longer necessary. OK okan@
This commit is contained in:
parent
5376c8c363
commit
caa175be7e
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $OpenBSD: client.c,v 1.260 2020/03/14 16:11:09 tim Exp $
|
* $OpenBSD: client.c,v 1.261 2020/03/16 17:50:44 tim Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -667,22 +667,24 @@ client_close(struct client_ctx *cc)
|
|||||||
void
|
void
|
||||||
client_set_name(struct client_ctx *cc)
|
client_set_name(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct winname *wn;
|
struct winname *wn, *wnnxt;
|
||||||
char *newname;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!xu_get_strprop(cc->win, ewmh[_NET_WM_NAME], &newname))
|
free(cc->name);
|
||||||
if (!xu_get_strprop(cc->win, XA_WM_NAME, &newname))
|
if (!xu_get_strprop(cc->win, ewmh[_NET_WM_NAME], &cc->name))
|
||||||
newname = xstrdup("");
|
if (!xu_get_strprop(cc->win, XA_WM_NAME, &cc->name))
|
||||||
|
cc->name = xstrdup("");
|
||||||
|
|
||||||
TAILQ_FOREACH(wn, &cc->nameq, entry) {
|
TAILQ_FOREACH_SAFE(wn, &cc->nameq, entry, wnnxt) {
|
||||||
if (strcmp(wn->name, newname) == 0)
|
if (strcmp(wn->name, cc->name) == 0) {
|
||||||
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
||||||
|
free(wn->name);
|
||||||
|
free(wn);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
cc->name = newname;
|
|
||||||
wn = xmalloc(sizeof(*wn));
|
wn = xmalloc(sizeof(*wn));
|
||||||
wn->name = xstrdup(newname);
|
wn->name = xstrdup(cc->name);
|
||||||
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
||||||
|
|
||||||
/* Garbage collection. */
|
/* Garbage collection. */
|
||||||
|
Loading…
Reference in New Issue
Block a user