From 5a5400dc61a7ed8de871bf5c439a226865eb03ea 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 3d50d7249..ec9ba10f9 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; }