(!1601) Xext: xres: ProcXResQueryClientResources() simplify payload write out
Collect the few bits in a local array, so one WriteToClient() call is sufficient. That's also easing further simplifications in upcoming commits. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									a186427921
								
							
						
					
					
						commit
						a809fc7d82
					
				
							
								
								
									
										30
									
								
								Xext/xres.c
								
								
								
								
							
							
						
						
									
										30
									
								
								Xext/xres.c
								
								
								
								
							|  | @ -307,9 +307,13 @@ ProcXResQueryClientResources(ClientPtr client) | ||||||
| 
 | 
 | ||||||
|     FindAllClientResources(clients[clientID], ResFindAllRes, counts); |     FindAllClientResources(clients[clientID], ResFindAllRes, counts); | ||||||
| 
 | 
 | ||||||
|  |     int cnt[lastResourceType + 1]; | ||||||
|  | 
 | ||||||
|     for (i = 0; i <= lastResourceType; i++) { |     for (i = 0; i <= lastResourceType; i++) { | ||||||
|         if (counts[i]) |         if (counts[i]) { | ||||||
|  |             cnt[num_types] = counts[i]; | ||||||
|             num_types++; |             num_types++; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     xXResQueryClientResourcesReply rep = { |     xXResQueryClientResourcesReply rep = { | ||||||
|  | @ -324,26 +328,20 @@ ProcXResQueryClientResources(ClientPtr client) | ||||||
|         swapl(&rep.num_types); |         swapl(&rep.num_types); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep); |     xXResType scratch[num_types]; | ||||||
| 
 | 
 | ||||||
|     if (num_types) { |     for (i = 0; i < num_types; i++) { | ||||||
|         xXResType scratch; |         scratch[i].resource_type = resourceTypeAtom(i + 1); | ||||||
|  |         scratch[i].count = cnt[i]; | ||||||
| 
 | 
 | ||||||
|         for (i = 0; i < lastResourceType; i++) { |         if (client->swapped) { | ||||||
|             if (!counts[i]) |             swapl(&scratch[i].resource_type); | ||||||
|                 continue; |             swapl(&scratch[i].count); | ||||||
| 
 |  | ||||||
|             scratch.resource_type = resourceTypeAtom(i + 1); |  | ||||||
|             scratch.count = counts[i]; |  | ||||||
| 
 |  | ||||||
|             if (client->swapped) { |  | ||||||
|                 swapl(&scratch.resource_type); |  | ||||||
|                 swapl(&scratch.count); |  | ||||||
|             } |  | ||||||
|             WriteToClient(client, sz_xXResType, &scratch); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     WriteToClient(client, sizeof(xXResQueryClientResourcesReply), &rep); | ||||||
|  |     WriteToClient(client, sizeof(scratch), scratch); | ||||||
|     return Success; |     return Success; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue