summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2010-10-30 15:50:45 +0200
committerHans de Goede <hdegoede@redhat.com>2010-10-30 15:50:45 +0200
commit986bf96b49753e849b8162e8557d8cef980e8c59 (patch)
tree9814aa975efb0fcacfa2d9a7a5de35c47b221db4
parentc106729a48a9e5080e37f92bc90f4405050149a3 (diff)
vdagentd: only realloc capabilities array if size changes
-rw-r--r--TODO1
-rw-r--r--vdagentd.c19
2 files changed, 11 insertions, 9 deletions
diff --git a/TODO b/TODO
index a75b703..72446a3 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,5 @@
-patch xorg driver to allow adding "random" resolutions
-make vdagent xorg client try to add "random" resolutions
--only realloc capabilities array if size changes
Maybe:
-Add support for selections with a target of STRING, which are
diff --git a/vdagentd.c b/vdagentd.c
index 444bbcf..ea3a16c 100644
--- a/vdagentd.c
+++ b/vdagentd.c
@@ -131,15 +131,18 @@ static void do_client_capabilities(struct vdagent_virtio_port *port,
VDAgentMessage *message_header,
VDAgentAnnounceCapabilities *caps)
{
- capabilities_size = VD_AGENT_CAPS_SIZE_FROM_MSG_SIZE(message_header->size);
+ int new_size = VD_AGENT_CAPS_SIZE_FROM_MSG_SIZE(message_header->size);
- free(capabilities);
- capabilities = malloc(capabilities_size * sizeof(uint32_t));
- if (!capabilities) {
- fprintf(logfile,
- "out of memory allocating capabilities array (read)\n");
- capabilities_size = 0;
- return;
+ if (capabilities_size != new_size) {
+ capabilities_size = new_size;
+ free(capabilities);
+ capabilities = malloc(capabilities_size * sizeof(uint32_t));
+ if (!capabilities) {
+ fprintf(logfile,
+ "out of memory allocating capabilities array (read)\n");
+ capabilities_size = 0;
+ return;
+ }
}
memcpy(capabilities, caps->caps, capabilities_size * sizeof(uint32_t));
if (caps->request)