mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 04:48:02 +02:00
Merge branch 'wip/clear-pointer' into 'main'
util: add a free_clear() helper to reset after free See merge request libinput/libinput!1472
This commit is contained in:
commit
ddce92d177
5 changed files with 16 additions and 8 deletions
|
|
@ -375,8 +375,7 @@ remove_device(struct libinput_lua_plugin *plugin, EvdevDevice *evdev)
|
||||||
list_for_each_safe(prop, &evdev->udev_properties_list, link) {
|
list_for_each_safe(prop, &evdev->udev_properties_list, link) {
|
||||||
udev_property_destroy(prop);
|
udev_property_destroy(prop);
|
||||||
}
|
}
|
||||||
free(evdev->name);
|
free_clear(&evdev->name);
|
||||||
evdev->name = NULL;
|
|
||||||
evdev->device = libinput_device_unref(evdev->device);
|
evdev->device = libinput_device_unref(evdev->device);
|
||||||
|
|
||||||
/* This device no longer exists but our lua code may have a
|
/* This device no longer exists but our lua code may have a
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "util-macros.h"
|
#include "util-macros.h"
|
||||||
|
#include "util-mem.h"
|
||||||
|
|
||||||
#define bit(x_) (1UL << (x_))
|
#define bit(x_) (1UL << (x_))
|
||||||
#define NBITS(b) (b * 8)
|
#define NBITS(b) (b * 8)
|
||||||
|
|
@ -281,8 +282,7 @@ infmask_new(void)
|
||||||
|
|
||||||
_nonnull_(1) static inline void infmask_reset(infmask_t *mask)
|
_nonnull_(1) static inline void infmask_reset(infmask_t *mask)
|
||||||
{
|
{
|
||||||
free(mask->mask);
|
free_clear(&mask->mask);
|
||||||
mask->mask = NULL;
|
|
||||||
mask->nmasks = 0;
|
mask->nmasks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,3 +186,14 @@ steal_fd(int *fd)
|
||||||
*fd = -1;
|
*fd = -1;
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees the pointer content and resets the data to NULL.
|
||||||
|
*/
|
||||||
|
#define free_clear(ptr_) \
|
||||||
|
do { \
|
||||||
|
typeof((ptr_)) _pp = (ptr_); \
|
||||||
|
typeof(*(ptr_)) _p = *_pp; \
|
||||||
|
*_pp = NULL; \
|
||||||
|
free(_p); \
|
||||||
|
} while(0)
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,7 @@ stringbuf_is_empty(struct stringbuf *b)
|
||||||
static inline void
|
static inline void
|
||||||
stringbuf_reset(struct stringbuf *b)
|
stringbuf_reset(struct stringbuf *b)
|
||||||
{
|
{
|
||||||
free(b->data);
|
free_clear(&b->data);
|
||||||
b->data = NULL;
|
|
||||||
b->sz = 0;
|
b->sz = 0;
|
||||||
b->len = 0;
|
b->len = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2372,8 +2372,7 @@ mainloop(struct record_context *ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(ctx->output_file.name_with_suffix);
|
free_clear(&ctx->output_file.name_with_suffix);
|
||||||
ctx->output_file.name_with_suffix = NULL;
|
|
||||||
} while (autorestart && !ctx->stop);
|
} while (autorestart && !ctx->stop);
|
||||||
|
|
||||||
sigprocmask(SIG_UNBLOCK, &mask, NULL);
|
sigprocmask(SIG_UNBLOCK, &mask, NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue