diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-02-25 12:20:25 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2014-02-25 12:22:31 +0100 |
commit | a1937e679f76758635d295287398abe526de2522 (patch) | |
tree | cd603e955ffdb264bfe5b2b08dd4b18240ff1038 /src/shared | |
parent | 23fae27185ddde98706faac0f45d77b11ecd66e6 (diff) | |
download | systemd-a1937e679f76758635d295287398abe526de2522.tar.gz systemd-a1937e679f76758635d295287398abe526de2522.tar.bz2 systemd-a1937e679f76758635d295287398abe526de2522.zip |
login: fix pos-array allocation
GREEDY_REALLOC takes a pointer to the real size, not the array-width as
argument. Therefore, our array is currently way to small to keep the seat
positions.
Introduce GREEDY_REALLOC0_T() as typed version of GREEDY_REALLOC and store
the array-width instead of array-size.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h index 9913fcefae..78b1444739 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -723,6 +723,15 @@ void* greedy_realloc0(void **p, size_t *allocated, size_t need); #define GREEDY_REALLOC0(array, allocated, need) \ greedy_realloc0((void**) &(array), &(allocated), sizeof((array)[0]) * (need)) +#define GREEDY_REALLOC0_T(array, count, need) \ + ({ \ + size_t _size = (count) * sizeof((array)[0]); \ + void *_ptr = GREEDY_REALLOC0((array), _size, (need)); \ + if (_ptr) \ + (count) = _size / sizeof((array)[0]); \ + _ptr; \ + }) + static inline void _reset_errno_(int *saved_errno) { errno = *saved_errno; } |