mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 06:38:02 +02:00
tools: fix a few memleaks on errors
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
261f8c910b
commit
cb976a2f95
2 changed files with 9 additions and 7 deletions
|
|
@ -35,10 +35,13 @@
|
|||
#include "src/util-mem.h"
|
||||
#include "src/util-strings.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct ei *, ei_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct ei_device *, ei_device_unref);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char SOCKETNAME[] = "eis.socket";
|
||||
struct ei *ei = ei_new(NULL);
|
||||
_cleanup_(ei_unrefp) struct ei *ei = ei_new(NULL);
|
||||
assert(ei);
|
||||
|
||||
ei_configure_name(ei, "ei-socket-client-demo");
|
||||
|
|
@ -58,10 +61,10 @@ int main(int argc, char **argv)
|
|||
.revents = 0,
|
||||
};
|
||||
|
||||
struct ei_device *ptr = ei_device_new(ei);
|
||||
_cleanup_(ei_device_unrefp) struct ei_device *ptr = ei_device_new(ei);
|
||||
ei_device_configure_capability(ptr, EI_DEVICE_CAP_POINTER);
|
||||
|
||||
struct ei_device *kbd = ei_device_new(ei);
|
||||
_cleanup_(ei_device_unrefp) struct ei_device *kbd = ei_device_new(ei);
|
||||
ei_device_configure_capability(kbd, EI_DEVICE_CAP_KEYBOARD);
|
||||
|
||||
bool stop = false;
|
||||
|
|
@ -127,7 +130,5 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
ei_unref(ei);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,11 @@ static void sighandler(int signal) {
|
|||
stop = true;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct eis *, eis_unref);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct eis *eis = eis_new(NULL);
|
||||
_cleanup_(eis_unrefp) struct eis *eis = eis_new(NULL);
|
||||
assert(eis);
|
||||
|
||||
_cleanup_free_ char *socketpath = NULL;
|
||||
|
|
@ -145,7 +147,6 @@ int main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
eis_unref(eis);
|
||||
unlink(socketpath);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue