From 7626e1f2e02e881a387c1b0b758a35b139935cf6 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 17 Jul 2024 13:06:54 +0200 Subject: [PATCH] (!1601) Xext: xres: ProcXResQueryClientResources(): put temporary int array on stack Simplify allocaton by putting the small temporary int array onto stack. This also allows further simplifications by upcoming commits. The upper bound is determined by the number of resource types registered in the server - this can only be increased by writing new extensions. Signed-off-by: Enrico Weigelt, metux IT consult --- Xext/xres.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Xext/xres.c b/Xext/xres.c index e540c7f1b..9fbbf8e5d 100644 --- a/Xext/xres.c +++ b/Xext/xres.c @@ -294,7 +294,6 @@ ProcXResQueryClientResources(ClientPtr client) REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq); int i, clientID, num_types = 0; - int *counts; clientID = CLIENT_ID(stuff->xid); @@ -303,7 +302,8 @@ ProcXResQueryClientResources(ClientPtr client) return BadValue; } - counts = calloc(lastResourceType + 1, sizeof(int)); + int counts[lastResourceType + 1]; + memset(counts, 0, sizeof(counts)); FindAllClientResources(clients[clientID], ResFindAllRes, counts); @@ -344,8 +344,6 @@ ProcXResQueryClientResources(ClientPtr client) } } - free(counts); - return Success; }