diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-01-30 12:35:01 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-01-30 17:04:56 +0100 |
commit | 3205c2c9a5a1a629b716c9188f89cd5dae02bc49 (patch) | |
tree | 726603d68b1a9980c9630f62ada9280050dfc1b7 | |
parent | 4aeb130affbad5bca058a2dc03bd3e41b2b39666 (diff) |
randr: Add a config_size helper function
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | src/vdagent-x11-randr.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/vdagent-x11-randr.c b/src/vdagent-x11-randr.c index 9577ec4..e48e519 100644 --- a/src/vdagent-x11-randr.c +++ b/src/vdagent-x11-randr.c @@ -622,6 +622,12 @@ static int same_monitor_configs(VDAgentMonitorsConfig *conf1, return 1; } +static int config_size(int num_of_monitors) +{ + return sizeof(VDAgentMonitorsConfig) + + num_of_monitors * sizeof(VDAgentMonConfig); +} + static VDAgentMonitorsConfig *get_current_mon_config(struct vdagent_x11 *x11) { int i, num_of_monitors = 0; @@ -630,8 +636,7 @@ static VDAgentMonitorsConfig *get_current_mon_config(struct vdagent_x11 *x11) XRRScreenResources *res = x11->randr.res; VDAgentMonitorsConfig *mon_config; - mon_config = calloc(1, sizeof(VDAgentMonitorsConfig) + - res->noutput * sizeof(VDAgentMonConfig)); + mon_config = calloc(1, config_size(res->noutput)); if (!mon_config) { syslog(LOG_ERR, "out of memory allocating current monitor config"); return NULL; |