From 4875a15ca61358a1c95b156b2279fce092451278 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 19 Jan 2022 00:45:43 +0100 Subject: Update libNX_X11 to upstream's libX11-1.7.3.1-10-gd60ede78 --- nx-X11/lib/src/xkb/XKBlibint.h | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'nx-X11/lib/src/xkb/XKBlibint.h') diff --git a/nx-X11/lib/src/xkb/XKBlibint.h b/nx-X11/lib/src/xkb/XKBlibint.h index dad48b703..0b9a096b4 100644 --- a/nx-X11/lib/src/xkb/XKBlibint.h +++ b/nx-X11/lib/src/xkb/XKBlibint.h @@ -29,6 +29,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include +#include "reallocarray.h" #define XkbMapPending (1<<0) #define XkbXlibNewKeyboard (1<<1) @@ -119,11 +120,26 @@ typedef struct _XkbReadBuffer { #define _XkbRealloc(o,s) Xrealloc((o),(s)) #define _XkbTypedAlloc(t) ((t *)Xmalloc(sizeof(t))) #define _XkbTypedCalloc(n,t) ((t *)Xcalloc((n),sizeof(t))) -#define _XkbTypedRealloc(o,n,t) \ - ((o) ? (t *)Xrealloc((o), (n)*sizeof(t)) : _XkbTypedCalloc(n,t)) -#define _XkbClearElems(a,f,l,t) bzero(&(a)[f], ((l)-(f)+1) * sizeof(t)) #define _XkbFree(p) Xfree(p) +/* Resizes array to hold new_num elements, zeroing newly added entries. + Destroys old array on failure. */ +#define _XkbResizeArray(array, old_num, new_num, type) \ + do { \ + if (array == NULL) { \ + array = _XkbTypedCalloc(new_num, type); \ + } else { \ + type *prev_array = array; \ + array = Xreallocarray(array, new_num, sizeof(type)); \ + if (_X_UNLIKELY((array) == NULL)) { \ + _XkbFree(prev_array); \ + } else if ((new_num) > (old_num)) { \ + bzero(&array[old_num], \ + ((new_num) - (old_num)) * sizeof(type)); \ + } \ + } \ + } while(0) + _XFUNCPROTOBEGIN extern void _XkbReloadDpy( -- cgit v1.2.3