diff options
author | Hans de Goede <hdegoede@redhat.com> | 2010-10-30 15:50:45 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2010-10-30 15:50:45 +0200 |
commit | 986bf96b49753e849b8162e8557d8cef980e8c59 (patch) | |
tree | 9814aa975efb0fcacfa2d9a7a5de35c47b221db4 | |
parent | c106729a48a9e5080e37f92bc90f4405050149a3 (diff) |
vdagentd: only realloc capabilities array if size changes
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | vdagentd.c | 19 |
2 files changed, 11 insertions, 9 deletions
@@ -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 @@ -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) |