diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-11-02 15:26:35 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-11-02 15:26:35 +0000 |
commit | dbca69c8a4f3e2d1ccb4f89152213b2861b33af6 (patch) | |
tree | f8963ef73903a7b4374adc2354dffbaa905112ac /xserver/Xext/xres.c | |
parent | 33b2029f322f3c238b7ba528083195ad8dde33e1 (diff) |
xserver 1.5.2. tested by ckuethe@, oga@, and others.
Diffstat (limited to 'xserver/Xext/xres.c')
-rw-r--r-- | xserver/Xext/xres.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/xserver/Xext/xres.c b/xserver/Xext/xres.c index 1617337bf..f444c4e69 100644 --- a/xserver/Xext/xres.c +++ b/xserver/Xext/xres.c @@ -17,6 +17,7 @@ #include "dixstruct.h" #include "extnsionst.h" #include "swaprep.h" +#include "registry.h" #include <X11/extensions/XResproto.h> #include "pixmapstr.h" #include "windowstr.h" @@ -63,10 +64,10 @@ ProcXResQueryClients (ClientPtr client) REQUEST_SIZE_MATCH(xXResQueryClientsReq); - current_clients = ALLOCATE_LOCAL((currentMaxClients - 1) * sizeof(int)); + current_clients = xalloc(currentMaxClients * sizeof(int)); num_clients = 0; - for(i = 1; i < currentMaxClients; i++) { + for(i = 0; i < currentMaxClients; i++) { if(clients[i]) { current_clients[num_clients] = i; num_clients++; @@ -101,7 +102,7 @@ ProcXResQueryClients (ClientPtr client) } } - DEALLOCATE_LOCAL(current_clients); + xfree(current_clients); return (client->noClientException); } @@ -127,14 +128,12 @@ ProcXResQueryClientResources (ClientPtr client) clientID = CLIENT_ID(stuff->xid); - /* we could remove the (clientID == 0) check if we wanted to allow - probing the X-server's resource usage */ - if(!clientID || (clientID >= currentMaxClients) || !clients[clientID]) { + if((clientID >= currentMaxClients) || !clients[clientID]) { client->errorValue = stuff->xid; return BadValue; } - counts = ALLOCATE_LOCAL((lastResourceType + 1) * sizeof(int)); + counts = xalloc((lastResourceType + 1) * sizeof(int)); memset(counts, 0, (lastResourceType + 1) * sizeof(int)); @@ -161,17 +160,20 @@ ProcXResQueryClientResources (ClientPtr client) if(num_types) { xXResType scratch; + char *name; for(i = 0; i < lastResourceType; i++) { if(!counts[i]) continue; - if(!ResourceNames[i + 1]) { + name = (char *)LookupResourceName(i + 1); + if (strcmp(name, XREGISTRY_UNKNOWN)) + scratch.resource_type = MakeAtom(name, strlen(name), TRUE); + else { char buf[40]; snprintf(buf, sizeof(buf), "Unregistered resource %i", i + 1); - RegisterResourceName(i + 1, buf); + scratch.resource_type = MakeAtom(buf, strlen(buf), TRUE); } - scratch.resource_type = ResourceNames[i + 1]; scratch.count = counts[i]; if(client->swapped) { @@ -183,7 +185,7 @@ ProcXResQueryClientResources (ClientPtr client) } } - DEALLOCATE_LOCAL(counts); + xfree(counts); return (client->noClientException); } @@ -250,9 +252,7 @@ ProcXResQueryClientPixmapBytes (ClientPtr client) clientID = CLIENT_ID(stuff->xid); - /* we could remove the (clientID == 0) check if we wanted to allow - probing the X-server's resource usage */ - if(!clientID || (clientID >= currentMaxClients) || !clients[clientID]) { + if((clientID >= currentMaxClients) || !clients[clientID]) { client->errorValue = stuff->xid; return BadValue; } @@ -387,15 +387,4 @@ ResExtensionInit(INITARGS) (void) AddExtension(XRES_NAME, 0, 0, ProcResDispatch, SProcResDispatch, ResResetProc, StandardMinorOpcode); - - RegisterResourceName(RT_NONE, "NONE"); - RegisterResourceName(RT_WINDOW, "WINDOW"); - RegisterResourceName(RT_PIXMAP, "PIXMAP"); - RegisterResourceName(RT_GC, "GC"); - RegisterResourceName(RT_FONT, "FONT"); - RegisterResourceName(RT_CURSOR, "CURSOR"); - RegisterResourceName(RT_COLORMAP, "COLORMAP"); - RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY"); - RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT"); - RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB"); } |