mirror of
https://github.com/mintycube/slock.git
synced 2024-10-22 14:05:51 +02:00
Add cleanup() to do free(locks) + XCloseDisplay()
This commit is contained in:
parent
137f0076c2
commit
1f66885fbf
16
slock.c
16
slock.c
@ -230,6 +230,13 @@ unlockscreen(Display *dpy, Lock *lock)
|
|||||||
free(lock);
|
free(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup(Display *dpy)
|
||||||
|
{
|
||||||
|
free(locks);
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
static Lock *
|
static Lock *
|
||||||
lockscreen(Display *dpy, int screen)
|
lockscreen(Display *dpy, int screen)
|
||||||
{
|
{
|
||||||
@ -349,8 +356,7 @@ main(int argc, char **argv) {
|
|||||||
/* did we actually manage to lock anything? */
|
/* did we actually manage to lock anything? */
|
||||||
if (nlocks == 0) {
|
if (nlocks == 0) {
|
||||||
/* nothing to protect */
|
/* nothing to protect */
|
||||||
free(locks);
|
cleanup(dpy);
|
||||||
XCloseDisplay(dpy);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,8 +364,7 @@ main(int argc, char **argv) {
|
|||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
free(locks);
|
cleanup(dpy);
|
||||||
XCloseDisplay(dpy);
|
|
||||||
die("slock: fork failed: %s\n", strerror(errno));
|
die("slock: fork failed: %s\n", strerror(errno));
|
||||||
case 0:
|
case 0:
|
||||||
if (close(ConnectionNumber(dpy)) < 0)
|
if (close(ConnectionNumber(dpy)) < 0)
|
||||||
@ -382,8 +387,7 @@ main(int argc, char **argv) {
|
|||||||
for (s = 0; s < nscreens; s++)
|
for (s = 0; s < nscreens; s++)
|
||||||
unlockscreen(dpy, locks[s]);
|
unlockscreen(dpy, locks[s]);
|
||||||
|
|
||||||
free(locks);
|
cleanup(dpy);
|
||||||
XCloseDisplay(dpy);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user